PYTHON BASICSChapter 5 · Collections
Labeling values
A dictionary stores values mapped to keys (labels). Define it with curly braces {} and key-value pairs separated by colons. Retrieve values using their keys.
Worked example
How it reads
{"name": "Sirius"}maps the key"name"to the value"Sirius".star["name"]retrieves the value stored under the key"name".

Cloud tip: If you try to look up a key that doesn't exist, Python will raise a KeyError. Check spelling.


