Lesson 78 +40 XP

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
  • in membership

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

  1. Run the starter and try every menu option.
  2. Add a check that prevents duplicate items.
  3. Print the list nicely, one item per line.
  4. 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.
  • in checks before removing.
  • remove() deletes by value.