Shopping List Program
🎯 Project: Shopping List Program
Let's build a shopping list manager using lists! This project will help you practice working with lists, list methods, and user interaction. You'll create a program that allows users to add, remove, and view items in their shopping list.
This project combines everything you've learned about lists, loops, conditionals, and functions to create a practical, useful application.
Project Requirements
Your shopping list program should:
- Display a menu of options
- Allow adding items to the list
- Allow removing items from the list
- Display all items in the list
- Show the total number of items
- Continue until user chooses to exit
Step-by-Step Implementation
Here's how to build the shopping list program:
shopping_list.py
# Step 1: Initialize empty shopping list
shopping_list = []
# Step 2: Create main loop
while True:
print("
Shopping List Manager")
print("1. Add item")
print("2. Remove item")
print("3. View list")
print("4. Exit")
choice = input("Enter choice: ")
if choice == "1":
item = input("Enter item to add: ")
shopping_list.append(item)
print(f"{item} added to list!")
elif choice == "2":
if shopping_list:
print("Current items:")
for i, item in enumerate(shopping_list, 1):
print(f"{i}. {item}")
item = input("Enter item to remove: ")
if item in shopping_list:
shopping_list.remove(item)
print(f"{item} removed!")
else:
print("Item not found!")
else:
print("List is empty!")
elif choice == "3":
if shopping_list:
print("
Your Shopping List:")
for i, item in enumerate(shopping_list, 1):
print(f"{i}. {item}")
print(f"
Total items: {len(shopping_list)}")
else:
print("Your list is empty!")
elif choice == "4":
print("Goodbye!")
break
else:
print("Invalid choice!")
Enhancement Ideas
Try adding these features to make your shopping list program even better:
- Save list to a file
- Load list from a file
- Mark items as purchased
- Sort items alphabetically
- Search for items
- Clear entire list
main.py
📤 Output
Click "Run" to execute...