CurriculumPython Dictionaries for KidsA dict is a stat sheet
Python Dictionaries Explained: Lookup by Key, Not Position
Named values, looked up by NAME instead of position — the key difference from a list.
A dict is a stat sheet
You know lists — a row of things, looked up by POSITION. A dict is different: it looks things up by NAME.
dragon = {"name": "Ember", "hp": 40} — a dict, with two keys: "name" and "hp". Each key holds one value.
dragon = {"name": "Ember", "hp": 40}dragon["hp"] gets the value stored under the "hp" key. Not "the second thing" — the thing NAMED hp.
print(dragon["hp"])Output
40That's the whole idea: a dict is a stat sheet where every value has a name, so you never have to remember which position it's in.
Check your understanding
dragon = {"name": "Ember", "hp": 40}. What does dragon["name"] give you?
dragon = {"name": "Ember", "hp": 40}
print(dragon["name"])Why: Ember. dragon["name"] looks up the value stored under the "name" key — by NAME, which is the whole point of a dict.
party = ["Ember", "Blaze"] is a LIST. dragon = {"name": "Ember"} is a DICT. How do you get the first item from each?
Why: party[0] for the list (position-based), dragon["name"] for the dict (name-based) — two different lookup systems for two different tools.
What you'll practice
dragon = {"name": "Ember", "hp": 40}. Print dragon["hp"] — the value stored under the "hp" key, looked up by name, not by position.
More from this topic
A dict is a stat sheet is one lesson inside Python Dictionaries for Kids — see the full lesson order and what the whole topic covers.
View the full topic →