Next →

What is a Dictionary?

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"}

Accessing Values

You access dictionary values using their keys:

student["name"] # returns "Alice"
student["age"] # returns 25

Adding or Changing Values

You can add new key-value pairs or update existing ones:

student["grade"] = "A"
student["age"] = 26

Why Dictionaries Matter in Analytics

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.