A simple command-line To-Do List application built with Python. This program allows users to add tasks, view tasks, and exit the application through a menu-driven interface.
Built as part of a Python fundamentals training track — focused on core backend logic: lists, loops, and menu-driven program structure.
- ➕ Add new tasks to your list
- 📋 View all your saved tasks
- 🚪 Exit the program safely
- 🔁 Menu keeps showing until you choose to exit
===== TO-DO LIST =====
1. Add Task
2. View Tasks
3. Exit
Enter your choice: 1
Enter your task: Study Python
Task added successfully!
===== TO-DO LIST =====
1. Add Task
2. View Tasks
3. Exit
Enter your choice: 2
Your tasks:
- Study Python
===== TO-DO LIST =====
1. Add Task
2. View Tasks
3. Exit
Enter your choice: 3
Thanks for using To-Do List!
python todo.pyRequires only Python 3 — no external libraries.
def show_menu():
print("\n===== TO-DO LIST =====")
print("1. Add Task")
print("2. View Tasks")
print("3. Exit")
def add_task(tasks):
task = input("Enter your task: ")
tasks.append(task)
print("Task added successfully.")
def view_tasks(tasks):
if not tasks:
print("No tasks yet. Add one first!")
return
print("Your tasks:")
for task in tasks:
print(f"- {task}")
def main():
tasks = []
while True:
show_menu()
choice = input("Enter your choice: ")
if choice == "1":
add_task(tasks)
elif choice == "2":
view_tasks(tasks)
elif choice == "3":
print("Thanks for using To-Do List!")
break
else:
print("Invalid choice. Please enter 1, 2, or 3.")
if __name__ == "__main__":
main()| Concept | Where it's used |
|---|---|
| Lists | tasks = [], tasks.append(task) |
| Menu-driven design | show_menu() + if/elif/else on user choice |
| Functions | add_task(), view_tasks(), main() |
| Loop control | while True + break on Exit |
| Empty state handling | if not tasks: check in view_tasks() |
- Python 3
Tabassum Naseer.