PROGRAM
def main():
# Initialize an empty list to store tasks
tasks = []
while True:
# Display the current list and available actions
print(f"\nTasks: {tasks}")
print("1: Add, 2: Update, 3: Remove, 4: Sort, 5: Exit")
choice = input("Action: ")
# 1. ADD TASK
if choice == "1":
new_task = input("New task: ")
[Link](new_task)
# 2. UPDATE TASK
elif choice == "2" and tasks:
try:
idx = int(input("Task number (1, 2...): ")) - 1
if 0 <= idx < len(tasks):
tasks[idx] = input("New description: ")
else:
print("Invalid task number.")
except ValueError:
print("Please enter a number.")
# 3. REMOVE TASK
elif choice == "3" and tasks:
try:
idx = int(input("Task number (1, 2...): ")) - 1
if 0 <= idx < len(tasks):
print(f"Removed: {[Link](idx)}")
else:
print("Invalid task number.")
except ValueError:
print("Please enter a number.")
# 4. SORT TASKS
elif choice == "4":
[Link]()
print("Sorted alphabetically!")
# 5. EXIT
elif choice == "5":
print("Goodbye!")
break
else:
print("Invalid input or no tasks available.")
if __name__ == "__main__":
main()
OUTPUT