Skip to main content

What are dictionaries?

Dictionaries store data in key-value pairs. Think of them like a real dictionary where you look up a word (key) to find its definition (value). Real-world examples:
  • Phone book: name > phone number
  • Menu: dish > price
  • User profile: username > user info

Creating dictionaries

Dictionaries use curly braces {} with key-value pairs separated by colons. Keys must be unique!

Accessing values

Changing dictionaries

Dictionary methods

Nested dictionaries

Common mistakes

What’s next?

Let’s explore tuples - like lists but unchangeable!

Tuples

Immutable sequences