Exercise 5 · Chapter: DictionariesRequired+50 XP
Update Inventory
You start with this inventory:
inventory = {"apples": 5, "bananas": 3}Read an item name and a quantity from input. If the item already exists, add the quantity to it. If it's a new item, add it to the inventory.
Print all items and quantities sorted alphabetically.
Example: if input is apples and 2:
apples: 7 bananas: 3
Need a hint?
3 available · costs 5 XP each
python
Output
Run your code to see the output here.