Dictionary Methods
Use get, keys, values, items, update, and pop.
Introduction
Python dicts have a rich set of methods for merging, transforming, and safely accessing data.
keys(), values(), items()
These return view objects that reflect changes to the dict. Convert to list if you need a snapshot.
d = {'a': 1, 'b': 2}
print(list(d.keys()))
print(list(d.values()))
print(list(d.items()))All lessons in this course
- Dictionary Basics
- Dictionary Methods
- Sets and Set Operations
- Dictionary Comprehensions