Dictionaries in Python

Dictionaries

Dictionaries are mutable, unordered collections of key-value pairs.

Creating a Dictionary

You can create a dictionary using curly braces {}.

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

Accessing Values

You can access values in a dictionary using their keys.

print(my_dict["age"])  # Output: 30