Dictionary Access in Python
Level 255 keystrokes
This accesses a value from a dictionary using a key. Dictionaries store key-value pairs.
Python code
# Create a dictionary of key-value pairs: "name" maps to "Alice", "age" to 251data = {"name": "Alice", "age": 25}# data["name"] looks up the value stored under the key "name"# Prints Alice (a missing key would raise KeyError)2print(data["name"])Output
Alice
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
"× 8:× 2,× 1(× 1)× 1[× 1]× 1{× 1}× 1=× 1