Two Items, One Bill

Python for AIEasy+10 XP+10

Two Items, One Bill

A café keeps its prices in a dictionary. The keys are drink names and the values are prices in rupees.

Write two_item_bill(menu, first_item, second_item) that returns what the two items cost together.

  • Both items are always on the menu.
  • The two items can be the same drink. Then you pay for it twice.

Examples

menu = {'tea': 20, 'coffee': 35}
first_item = 'tea'
second_item = 'coffee'
returns 55
menu = {"tea": 20, "coffee": 35, "juice": 50}
first_item = "juice"
second_item = "tea"
returns 70
menu = {"tea": 20, "coffee": 35}
first_item = "coffee"
second_item = "coffee"
returns 70

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