dreamcode
Back to map
Dictionaries · Lesson 6 of 6
+15 XP on finish
PYTHON BASICS

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.

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.
main.py
PYTHON
real Python, runs in your browser
CONSOLE
- run your code to see output -