Home / Python / Collections

Dictionaries

A dictionary stores key and value pairs, like a phone book. Look values up by key instead of by position. functions often return dictionaries to bundle results.

person = {"name": "Asha", "age": 30}
print(person["name"])
person["city"] = "Pune"

Test yourself on this