Dictionaries in Python are a collection of key-value pairs — meaning every item in the dictionary has a key and an associated value.
If we want to write down prices of some items in a grocery store, normally we will note them on a piece of paper like this:
eggs - 4.99
banana - 1.49
cheese- 4.5
eggplant - 2.5
bread - 3.99
In Python dictionary lingo, the name of each item is “key” and the associated price is “value” and they appear in pairs. We can represent the same in a Python dictionary data structure as follows:
{"eggs": 4.99,
"banana": 1.49,
"cheese": 4.5,
"eggplant": 2.5,
"bread": 3.99}
Notice the differences. In the dictionary
#dictionary #python #artificial-intelligence #dictionaries #python dictionary #working with python dictionaries