Dictionaries · routine
Inventory value
An inventory maps each item to a dictionary with its price and qty: {"pen": {"price": 1.5, "qty": 4}}.
Write inventory_value(inventory) returning the total value (price × quantity, summed), rounded to 2 decimals.
- right answers
- arguments left as they should be
Run adds print(inventory_value({"pen": {"price": 1.5, "qty": 4}})) after your code, to try it.
Stuck on the idea rather than the code? The Grouping and nested data lesson walks through it.