Dictionaries

A dictionary stores data in key-value pairs. Keys must be unique and immutable.

person = {"name": "Alice", "age": 25}
print(person["name"])  # Output: Alice

You can add, update, or remove key-value pairs.

person["city"] = "Mumbai"
person["age"] = 26
del person["city"]
← Prev