Preplp
Daily Python
Day 7Python~40 min

Lists

Store, add, remove, and loop over items

Track progress0/15 days
x

What you'll learn

listappendremoveenumeratewhile
  • Use list methods like append and remove
  • Build a menu-driven shopping list app

Lesson & examples

Read the code, then the explanation — try changing values before the project.

List basics
shopping_list = ["Milk", "Eggs", "Bread"]
shopping_list.append("Butter")
for index, item in enumerate(shopping_list):
    print(f"{index + 1}. {item}")

Today's exercise: Shopping List App

Menu app to view, add, remove, and clear a shopping list.

Steps

  1. 1

    Menu loop

    Show options 1–5 in a while True loop.

  2. 2

    CRUD actions

    Implement view, add, remove, and clear on the list.

Full project source — copy into a folder or use the zip above

starter.py
shopping_list = []

def show_menu():
    print("\n--- Shopping List Menu ---")
    print("1. View list")
    print("2. Add item")
    print("3. Remove item")
    print("4. Clear list")
    print("5. Exit")

while True:
    show_menu()
    choice = input("Enter your choice (1-5): ")
    if choice == "1":
        if not shopping_list:
            print("Your list is empty.")
        else:
            for i, item in enumerate(shopping_list, 1):
                print(f"{i}. {item}")
    elif choice == "2":
        item = input("Item to add: ")
        shopping_list.append(item)
        print(f"{item} added.")
    elif choice == "3":
        item = input("Item to remove: ")
        if item in shopping_list:
            shopping_list.remove(item)
        else:
            print("Item not found.")
    elif choice == "4":
        shopping_list.clear()
        print("List cleared.")
    elif choice == "5":
        print("Goodbye!")
        break
    else:
        print("Invalid choice.")

One rehearsal platform

Certification mocks, daily lessons, project labs, and in-browser drills

Structured for exam day and portfolio proof — timed tests, guided builds, and quick reps on one platform.