0Pricing
Python Academy · Lesson

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

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