Dictionary
Published May 11, 2021Updated Mar 7, 2023
Contribute to Docs
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}
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn more on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours