Shopping List: Add and Remove Items
Beginner · Write the code · from Python Lists: Create, Access, Modify, and Loop Through Lists
From the lesson: Python Lists: Create, Access, Modify, and Loop Through Lists
Think about your favorite music playlist. It has a bunch of songs stored in a specific order. You can add new songs, remove old ones, rearrange them, or skip to song number five.
Read the lessonYou have a shopping list. Do these steps in order:
1. Add "bread" to the end of the list
2. Remove "milk" from the list
3. Print the final list
Expected output:
['eggs', 'cheese', 'butter', 'bread']shopping = ["eggs", "milk", "cheese", "butter"]
# Step 1: Add "bread" to the end
# Step 2: Remove "milk"
# Step 3: Print the list
More Lists exercises
- Create a List and Print Its LengthBeginner
- Access the Last Item with Negative IndexingBeginner
- Fix the Bug: IndexErrorBeginner
- Sum All Numbers Using a LoopBeginner
- Find the Largest Number Without max()Intermediate
- Predict the Output: List AliasingIntermediate
- Reverse a List Without reverse() or [::-1]Intermediate
All Python exercises · 50 practice problems · Data Structures quiz