Build a simple shopping list application that helps users keep track of items they need to buy. This assignment will practice lists, functions, and user interaction.
Your shopping list app must have these features:
Write the following functions:
display_list(shopping_list)
- Shows all items in the list
# Example output:
Shopping List:
1. Milk
2. Bread
3. Eggs
add_item(shopping_list, item)
- Adds an item to the list
remove_item(shopping_list, item_number)
- Removes item by position
Create a menu-driven program:
=== SHOPPING LIST MANAGER ===
1. View list
2. Add item
3. Remove item
4. Clear list
5. Exit
Enter choice:
Requirements:
=== SHOPPING LIST MANAGER ===
1. View list
2. Add item
3. Remove item
4. Clear list
5. Exit
Enter choice: 2
Enter item to add: Milk
Added "Milk" to your list!
Enter choice: 2
Enter item to add: Bread
Added "Bread" to your list!
Enter choice: 1
Shopping List:
1. Milk
2. Bread
Enter choice: 3
Enter item number to remove: 1
Removed "Milk" from your list!
Enter choice: 5
Goodbye!
mark_purchased(shopping_list, item_number)
to mark items as boughtdef display_list(shopping_list):
"""Display all items in the shopping list"""
# TODO: Your code here
pass
def add_item(shopping_list, item):
"""Add item to list if not duplicate"""
# TODO: Your code here
pass
def remove_item(shopping_list, item_number):
"""Remove item at given position"""
# TODO: Your code here
pass
def main():
shopping_list = []
while True:
print("\n=== SHOPPING LIST MANAGER ===")
print("1. View list")
print("2. Add item")
print("3. Remove item")
print("4. Clear list")
print("5. Exit")
choice = input("\nEnter choice: ")
# TODO: Handle each choice
# Run the program
main()