Open oldoc63 opened 1 year ago
A dictionary is an unordered set of key: value pairs.
It provides us with a way to map pieces of data to each other so that we can quickly find values that are associated with one another.
Suppose we want to store the prices of various items sold at a cafe:
In Python we can create a dictionary called menu to store this data:
Notice that:
It's considered good practice to insert a space ( ) after each comma, but our code will still run without the space.
A dictionary is an unordered set of key: value pairs.
It provides us with a way to map pieces of data to each other so that we can quickly find values that are associated with one another.
Suppose we want to store the prices of various items sold at a cafe:
In Python we can create a dictionary called menu to store this data: