Back to Lesson

Inventory Merge

Merge and consolidate multiple dictionaries.

Instructions

  • Given
    base = {"apples": 10, "bananas": 15}
    and
    shipment = {"bananas": 20, "oranges": 5}
    .
  • We want to add these amounts together!
  • Write a loop over
    shipment.items()
    . For each key and amount, add the amount to the matching key in
    base
    using
    .get()
    to provide a default of 0.
  • Print the final
    base
    dict.
main.py
main.py