Dictionary

Dictionary

A dictionary is an unordered set of (key, value) pairs. It provides a way to map pieces of data to each other, and allows for quick access to values associated to keys.

Syntax

The syntax of a dictionary is as follows:

dictionary = {
  key1: value1,
  key2: value2,
  key3: value3
}

For example:

coffee_shop = {
"cold brew": 3.50,
"latte": 4.25,
"cappucino": 3.99
}
Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn More on Codecademy

Edit this page on GitHub

Contributors