Nested Dict in Python
Level 3111 keystrokes
This accesses a value in a nested dictionary using chained bracket notation.
Python code
# Create a dictionary where values are also dictionaries1users = { # alice's data is a nested dictionary2 "alice": {"age": 30, "city": "NYC"}, # bob's data is also a nested dictionary3 "bob": {"age": 25, "city": "LA"}4}# First bracket gets alice's dict, second gets city value5print(users["alice"]["city"])Output
NYC
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.
"× 20:× 6,× 3{× 3}× 3[× 2]× 2(× 1)× 1=× 1