Dictionaries
Storing key-value pairs, accessing a value, adding/updating, safe access, and iterating with a loop.
Simple enough for a 5-year-old to understand
Dictionary: labeled boxes
While a list accesses elements by number, a dictionary accesses them by KEY. It's ideal for holding the attributes of a real person.
person = {"name": "Alex", "age": 36}print(person["name"])print(person["age"])Adding and updating
person = {"name": "Alex"}person["city"] = "London"person["name"] = "Alex L."print(person)🎯 Exercise & Practice
Test what you've learned — answer, write code, check instantly. (1 left)