The dragon explains
The Full Roster Check
The dragon: You know dicts, and you know lists. Now put a list of dicts together — a whole roster.
The dragon: party = [{"name": "Ember"}, {"name": "Blaze"}] — a LIST holding DICTS. Loop over it, and each item is one dict.
example.pyPython 3party = [{"name": "Ember"}, {"name": "Blaze"}]for dragon in party: print(dragon["name"])
OutputEmber BlazeThe dragon: Add an if/elif/else INSIDE that loop, using one of the dict's own keys, and you can react differently to each dragon based on its own stats.
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
party = [{"hp": 10}, {"hp": 80}]. Using if hp < 20 / else, how many lines print for a loop that reacts to each dragon?
- 2 — one reaction per dragonCorrect
- 4 — every dragon checked against every rule
Why: 2. One pass through the loop per dragon, one decision per pass, one line printed — exactly like every earlier boss's loop-plus-branch pattern.
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 = [{"name": "Ember"}, {"name": "Blaze"}, {"name": "Frost"}]. Loop over the party and print each dragon's name — using for dragon in party: dragon["name"], 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.