#502 · Dictionaries and sets · Beginner · 25 XP · about 4 min
A cafe's menu is a dictionary that maps each item to its price in cents. An order is a list of the items a table asked for, with an item listed once for every time it was ordered.
Write order_total(menu, order) that returns the total in cents. Items that are not on the menu are left out of the total, because the kitchen cannot make them. Names must match the menu exactly.
menu = {'coffee': 250, 'muffin': 300, 'juice': 400} order_total(menu, ['coffee', 'coffee', 'muffin']) # returns 800 order_total(menu, ['juice', 'pizza']) # returns 400 order_total(menu, []) # returns 0
First solves only, ranked by stars and then time.