Python Lists
💡
Exercise 24

Inventory 15 XP Medium

Ctrl+Enter Run Ctrl+S Save

You can loop through a list using a for loop:

colors = ['red', 'green', 'blue'] for color in colors: print(color)

The variable color takes on each value in the list, one at a time.

You can also use enumerate() to get both the index and value:

for i, color in enumerate(colors): print(f'{i}: {color}')
📋 Instructions
Create an inventory list: ```python inventory = ['sword', 'shield', 'potion', 'bow', 'arrow'] ``` Loop through it and print each item with its number: ``` 1. sword 2. shield 3. potion 4. bow 5. arrow ``` Hint: Use `enumerate()` with a start of 1!
Use: for i, item in enumerate(inventory, 1): then print(f'{i}. {item}'). You've got this — take it step by step!
⚠️ Try solving it yourself first — you'll learn more!
colors = ['red', 'green', 'blue']

for color in colors:
    print(color)
🧪 Test Cases
Input
Run your code
Expected
1. sword 2. shield 3. potion ...
Expected output (5 lines)
main.py
Hi! I'm Rex 👋
Output
Ready. Press ▶ Run or Ctrl+Enter.