Back to Lesson
Inventory Merge
Merge and consolidate multiple dictionaries.
Instructions
- Givenand
base = {"apples": 10, "bananas": 15}.shipment = {"bananas": 20, "oranges": 5} - We want to add these amounts together!
- Write a loop over. For each key and amount, add the amount to the matching key in
shipment.items()usingbaseto provide a default of 0..get() - Print the finaldict.
base
main.py
main.py
Ctrl + Enter