Bugsy
Explains
3 hearts left

Dictionaries

New idea

What is Sam's index?

Your phone holds 500 contacts. To call Sam you don't think "Sam is contact number 312". You just look up the name. A list can only find things by position, and most of the time you don't know the position.

A dictionary stores pairs: a key and its value. You write it in curly braces, with a colon between each key and its value: ages = {"sam": 12, "mia": 9}.

You read a value by putting its key in square brackets: ages["sam"] gives 12. Like a real dictionary, you look up the word and get its meaning, without counting pages.