The dragon explains
The Grand Inventory Check
The dragon: You know indexing, slicing, append, remove, and shared references. Now put a loop and a decision on top.
The dragon: for item in a_list: visits every item — same pattern you've already used with whileloops' patrol.
example.pyPython 3values = [50, 200, 10]for v in values: print(v)
Output50 200 10The dragon: Add an if/elif/else inside that loop, and you can react DIFFERENTLY to each item, all in one pass through the list.
Quick check
Check your understanding
Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.
Question 1 of 1
values = [50, 200, 10]. Using if/elif/else with 150 and 20 as cutoffs, how many lines print?
- 3 — one label per valueCorrect
- 9 — every value checked against every rule
- 1 — only the biggest value matters
Why: Three values, three passes, one label each — the loop and the conditional work together exactly like they did in the whileloops boss, just walking a list instead of counting with range().
In the game
What you'll practice
Three levels in the game: one guided first try with the shape of the answer already there, then two to solve on your own.
- 1
GuidedYour first try
party = ["Ember", "Blaze", "Frost"]. Loop over the party and print a greeting for each name — using for name in party:, not indexing.
- +2
PracticeTwo more, on your own
This lesson is part of PRO.
PRO is a one-time $49.99 purchase, no subscription, and unlocks this whole topic along with everything else. Topics 1–3 are free, start to finish.
Unlock this lesson with PROStuck three times? The game offers the answer — unasked.