Loading lessons...
Project 6: Shopping List Manager
Project 6: Shopping List Manager
A menu-driven program that manages a shopping list with add, remove, and show options.
The goal
Show a menu, let the user add items, remove items, and list everything, looping until they choose to exit.
What you practice
- while loops
- if / elif branches
- Lists
inmembership
Starter code
shopping = []
while True:
print("\n1. Add item")
print("2. Remove item")
print("3. Show list")
print("4. Exit")
choice = input("Choose: ")
if choice == "4":
break
elif choice == "1":
item = input("Item to add: ")
shopping.append(item)
elif choice == "2":
item = input("Item to remove: ")
if item in shopping:
shopping.remove(item)
else:
print("Not on the list.")
elif choice == "3":
print(shopping)
else:
print("Unknown choice")
Step-by-step
- Run the starter and try every menu option.
- Add a check that prevents duplicate items.
- Print the list nicely, one item per line.
- Re-run and test edge cases.
Checklist
- [ ] The menu loops until exit
- [ ] Items can be added
- [ ] Items can be removed safely
- [ ] The list is displayed
- [ ] Bad choices show a message
TL;DR
- A while True menu with break exits.
inchecks before removing.- remove() deletes by value.