What Changed Overnight?

Python for AIMedium+10 XP+10

What Changed Overnight?

A stall writes its prices down every evening. You have yesterday's dictionary and today's.

Write changed_items(old_prices, new_prices) that returns a list of the items that are in both dictionaries but have a different price today.

  • Ignore items that are only in one of the two.
  • Sort the list alphabetically.

Examples

old_prices = {'apple': 40, 'fig': 80}
new_prices = {'apple': 45, 'fig': 80}
returns ['apple']
old_prices = {"mango": 90, "kiwi": 35, "apple": 40}
new_prices = {"apple": 40, "kiwi": 30, "mango": 95}
returns ['kiwi', 'mango']
old_prices = {"apple": 40}
new_prices = {"apple": 40}
returns []

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run