python / beginner
Snippet
Python Dictionaries
Dictionaries store data in key-value pairs, making it easy to retrieve information using a unique key instead of a numerical index.
snippet.py
1
2
user = {"name": "Alice", "level": 5}print(user["name"])
Breakdown
1
user = {"name": "Alice", "level": 5}
Create a dictionary with keys 'name' and 'level' assigned to specific values.
2
print(user["name"])
Access and print the value associated with the key 'name'.