Shopping Cart Example
Create a program that starts with an empty list. Ask the user to input 3 tasks. Add them to the list, then "complete" the second task by removing it from the list. Finally, print the remaining tasks in alphabetical order.
#Add Empty list
tasks= [];
for i in range(3):
task = input(f"Enter task {i+1}: ")
tasks.append(task)
print(f"\nYour curent task: {tasks}")
completed_task = tasks.pop(1)
print(f"\n Completed task: {completed_task}")
remaining_tasks = sorted(tasks)
print(f"\nRemaining tasks (alphabetical order): ")
for task in remaining_tasks:
print(f"- {task}")
Top comments (1)
How best can we solve the question?