def display_tasks(tasks):
if not tasks:
print("Your to-do list is empty.")
else:
print("Your To-Do List:")
for index, task in enumerate(tasks, start=1):
print(f"{index}. {task}")
def main():
tasks = []
while True:
print("\nOptions:")
print("1. Add task")
print("2. Remove task")
print("3. View tasks")
print("4. Exit")
choice = input("Select an option (1-4): ")
if choice == '1':
task = input("Enter the task: ")
tasks.append(task)
print(f"Task '{task}' added.")
elif choice == '2':
display_tasks(tasks)
try:
task_index = int(input("Enter the task number to remove: ")) - 1
if 0 <= task_index < len(tasks):
removed_task = tasks.pop(task_index)
print(f"Task '{removed_task}' removed.")
else:
print("Invalid task number.")
except ValueError:
print("Please enter a valid number.")
elif choice == '3':
display_tasks(tasks)
elif choice == '4':
print("Exiting the To-Do List Manager.")
break
else:
print("Invalid option. Please try again.")
if __name__ == "__main__":
main()