Dictionaries in Python — a practical guide to Python dictionaries with clear examples you can reuse in real projects.
Python Tutorial Series (24/95). Prefer one article? Read the complete Python tutorial.
Short description
Dicts are the go-to structure for JSON-like data. Keys must be hashable (strings/numbers/tuples).
Dict basics
user = {'name': 'Asha', 'age': 28}
user['city'] = 'Pune'
print(user.get('email', 'N/A'))
for key, value in user.items():
print(key, value)