Challenge 3: Safe Lookup Report — Possible Solution ==================================================================== inventory = {"apples": 10, "bananas": 5} items_to_check = ["apples", "bananas", "cherries"] for item in items_to_check: stock = inventory.get(item, 0) print(f"{item}: {stock} in stock") Output: apples: 10 in stock bananas: 5 in stock cherries: 0 in stock WHY THIS WORKS AS AN ANSWER ------------------------------ inventory.get(item, 0) is the exact defensive-lookup pattern the chapter's warn-box called out — inventory[item] would raise a KeyError the moment item is "cherries", since that key was never added to inventory, crashing the whole loop partway through. .get()'s second argument (0) supplies a sensible fallback specifically for this domain: an item that isn't in the inventory dictionary at all genuinely has zero units in stock, so 0 is both a safe default AND the factually correct answer here, not just a crash-avoidance trick. The loop then reuses the plain for-item-in-list iteration from Chapter 4 and the f-string formatting from Chapter 5 to print one report line per item, regardless of whether that item exists in inventory or not.