print("To-Do List Application")
tasks = []
while True:
print("1. Add Task")
print("2. View Tasks")
print("3. Mark Task as Completed")
print("4. Exit")
choice = int(input("Enter your choice: "))
if choice == 1:
task = input("Enter the task: ")
tasks.append({"task": task, "completed": False})
print("Task added successfully!")
elif choice == 2:
print("Tasks:")
for i, task in enumerate(tasks, 1):
status = "Completed" if task["completed"] else "Pending"
print(f"{i}. {task['task']} - {status}")
elif choice == 3:
task_number = int(input("Enter the task number to mark as completed: "))
if 1 <= task_number <= len(tasks):
tasks[task_number - 1]["completed"] = True
print("Task marked as completed!")
else:
print("Invalid task number.")
elif choice == 4:
print("Exiting the application.")
break
else:
print("Invalid choice. Please try again.")
tasks = []
while True:
print("1. Add Task")
print("2. View Tasks")
print("3. Mark Task as Completed")
print("4. Exit")
choice = int(input("Enter your choice: "))
if choice == 1:
task = input("Enter the task: ")
tasks.append({"task": task, "completed": False})
print("Task added successfully!")
elif choice == 2:
print("Tasks:")
for i, task in enumerate(tasks, 1):
status = "Completed" if task["completed"] else "Pending"
print(f"{i}. {task['task']} - {status}")
elif choice == 3:
task_number = int(input("Enter the task number to mark as completed: "))
if 1 <= task_number <= len(tasks):
tasks[task_number - 1]["completed"] = True
print("Task marked as completed!")
else:
print("Invalid task number.")
elif choice == 4:
print("Exiting the application.")
break
else:
print("Invalid choice. Please try again.")