CurriculumThe Dragon's Stat Sheet
Python Dictionaries for Kids
A dictionary is a stat sheet — a value looked up by its name, not by its position in a list.
What this topic covers
Children arrive at this topic already fluent with lists, which look things up by position. A dictionary asks a genuinely different question — not 'what's in slot zero' but 'what's stored under this name' — and the topic draws that contrast explicitly from its first example, rather than letting the two lookup styles blur together.
Updating a dictionary follows the same 'read the old value to make the new one' pattern already taught for variables, one level of indirection deeper, and adding a brand new key is shown to require no special command at all — just naming it.
The last new idea is a real crash: asking for a key that was never set raises a KeyError, and .get() with a default is the fix, taught by first showing the actual error rather than describing it in the abstract. The topic closes with a list of dictionaries — a whole party roster — combining every topic taught so far.
Python from this topic
dragon = {"name": "Ember", "hp": 40}
print(dragon["hp"])Output
40Python covered here
- Creating a dictionary and looking up a value by key
- The difference between key-based and position-based lookup
- Updating a key's value
- Adding a brand new key
- The KeyError from a missing key, and .get() with a default
- Looping over a list of dictionaries
The mistake this topic is built to fix
Common mistakeA child tries to look up a dictionary value by position, the way they would with a list.
A list and a dictionary answer different questions — 'what's here' versus 'what's named this' — and conflating them produces code that looks plausible but asks the wrong question. The topic makes the contrast explicit rather than assuming it's obvious.
The lessons, in order
- A dict is a stat sheetNamed values, looked up by NAME instead of position — the key difference from a list.3 exercises
- Updating a stat, adding a new oneRead the old value to make the new one — and setting a NEW key creates it on the spot.3 exercises
- A missing key crashes — .get() doesn't have todragon["mana"] crashes if mana was never set. dragon.get("mana", 0) doesn't.3 exercises
- The Full Roster CheckDicts, lists, loops, and decisions — a whole party, checked one dragon at a time.3 exercises
- Tally and groupA dict can count things for you — one running total per key, all through one loop.3 exercises
Lessons unlock in order within a topic, so nothing arrives before the idea it depends on. This topic is part of PRO — $6.99 unlocks it along with everything else.
Try it now
The very first level needs no account at all — see whether it clicks before signing up for anything.
Play the first level free →