Dictionaries in depth

Beyond storing key→value, dictionaries shine when you iterate them and look things up safely.

`d.get(key, default)` avoids a crash when a key is missing. `d.values()` and `d.items()` let you loop over the contents. `key in d` tests membership.

prices = {"pen": 2, "book": 8}
print(prices.get("cup", 0))   # 0 — safe default

More lessons in Pythonic essentials