0Pricing
Python Academy · Lesson

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

  1. Dictionary Basics
  2. Dictionary Methods
  3. Sets and Set Operations
  4. Dictionary Comprehensions
← Back to Python Academy