tasks = []
def show_menu():
print("\n--- TO DO LIST ---")
print("1. Add task")
print("2. View tasks")
print("3. Exit")
def add_task():
task = input("Enter a new task: ")
tasks.append(task)
print("Task added!")
def view_tasks():
if len(tasks) == 0:
print("No tasks yet.")
else:
for i, task in enumerate(tasks, start=1):
print(i, "-", task)
while True:
show_menu()
choice = input("Choose an option: ")
if choice == "1":
add_task()
elif choice == "2":
view_tasks()
elif choice == "3":
print("Goodbye!")
break
else:
print("Invalid option")
tasks = []
def show_menu():
print("\n--- TO DO LIST ---")
print("1. Add task")
print("2. View tasks")
print("3. Exit")
def add_task():
task = input("Enter a new task: ")
tasks.append(task)
print("Task added!")
def view_tasks():
if len(tasks) == 0:
print("No tasks yet.")
else:
for i, task in enumerate(tasks, start=1):
print(i, "-", task)
while True:
show_menu()
choice = input("Choose an option: ")