todo_list = [] def add_task(task): todo_list.append(task) print(f"Task added: {task}") def view_tasks(): print("To-Do List:") for i, task in enumerate(todo_list): print(f"{i + 1}. {task}") def remove_task(index): try: task = todo_list.pop(index - 1) print(f"Task removed: {task}") except IndexError: print("Invalid index. Please enter a valid task number.") while True: choice = input("Enter a command (add, view, remove, exit): ") if choice == "add": task = input("Enter a task to add: ") add_task(task) elif choice == "view": view_tasks() elif choice == "remove": index = int(input("Enter the number of the task to remove: ")) ...











Comments
Post a Comment