Dictionary Basics
Create dicts, access values by key, and iterate over them.
Introduction
Dictionaries store key-value pairs with O(1) average lookup. Keys must be hashable; values can be anything.
Creating a Dict
d = {'name': 'Alice', 'age': 30} or d = dict(name='Alice', age=30). Keys must be unique and hashable.
d = {'name': 'Alice', 'age': 30}
print(d)All lessons in this course
- Dictionary Basics
- Dictionary Methods
- Sets and Set Operations
- Dictionary Comprehensions