drag to orbit Β· scroll to zoom
← Playground

πŸ—„οΈ Lockers Β· dictionary

A dictionary is a row of labeled lockers. The key is the label on the door; the value is what's inside. Pick a key to open its locker.

Pick a key
locker["apple"] β†’ 3
Pick a key, then open its locker.
Python code
locker = {"apple": 3, "banana": 5, "cherry": 2} locker["apple"]

πŸ’‘ The label is the key. It opens exactly one locker, straight to its value β€” no counting through the row. A key that isn't there causes a KeyError.