Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Step 1: Create an empty list
- shopping_list = []
- # Step 2: Get 5 items from the user
- for i in range(5):
- item = input("Enter an item to add to your shopping list: ")
- shopping_list.append(item)
- # Step 3: Print the shopping list
- print("\nYour shopping list:", shopping_list)
- # Step 4: Ask for an item to remove
- remove_item = input("\nWhich item would you like to remove? ")
- # Step 5: Remove the item if it exists
- if remove_item in shopping_list:
- shopping_list.remove(remove_item)
- else:
- print(f"{remove_item} was not found in your shopping list.")
- # Step 6: Print the updated list
- print("\nUpdated shopping list:", shopping_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement