A dictionary is a collection of key-value pairs. It lets you store data where each value is accessed by a unique key, similar to a real-world dictionary.
Dictionaries are defined using curly braces {}
:
student = {"name": "Alice", "age": 25, "city": "London"}
You access dictionary values using their keys:
student["name"] # returns "Alice"
student["age"] # returns 25
You can add new key-value pairs or update existing ones:
student["grade"] = "A"
student["age"] = 26
Dictionaries are useful for storing labeled data like records, metadata, or configuration settings. They help you organize information by meaningful keys rather than numeric indexes.