Todo List
Todo List
tasks = []
def show_menu():
print("\nTo-Do List Menu:")
print("1. Show Tasks")
print("2. Add Task")
print("3. Remove Task")
print("4. Exit")
def show_tasks():
if not tasks:
print("No tasks to show.")
else:
print("Tasks:")
for i, task in enumerate(tasks, start=1):
print(f"{i}. {task}")
def add_task():
task = input("Enter task: ")
tasks.append(task)
print("Task added.")
def remove_task():
show_tasks()
try:
index = int(input("Enter task number to remove: ")) - 1
if 0 <= index < len(tasks):
removed = tasks.pop(index)
print(f"Removed: {removed}")
else:
print("Invalid task number.")
except ValueError:
print("Please enter a valid number.")
while True:
show_menu()
choice = input("Enter your choice: ")
if choice == '1':
show_tasks()
elif choice == '2':
add_task()
elif choice == '3':
remove_task()
elif choice == '4':
print("Exiting...")
break
else:
print("Invalid choice. Try again.")