
Learn Python Data Structures
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. ` tasks= []; for i in range(4): 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}") `
Continue reading on Dev.to Python
Opens in a new tab



