Dictionary
noun
say it: “DIK-shuh-nair-ee” /ˈdɪkʃəˌnɛri/
A Python collection that stores values under keys, in curly braces, so you look things up by name instead of by position.
What is a dictionary in Python?
A dictionary stores values under keys, so you look things up by name instead of by position. It uses curly braces.
prices = {"coffee": 3.5, "muffin": 2.75}
print(prices["coffee"]) # 3.5
prices["tea"] = 3.0 # add a new item
In a sentence
- “The menu is a dictionary from item names to prices.”
- “prices["tea"] = 3.0 adds a new entry to the dictionary.”
Level: Apprentice · More Python terms at this level
Updated