This is the same task as the previous one, with a different restriction.
fruit_prices maps a fruit name to its price and purchases is a list of
(fruit, quantity) tuples. Write total_price_no_loops(fruit_prices, purchases)
that returns the total cost of the purchase.
Do not write an explicit for or while loop -- use the sum function
together with a comprehension.
Example
total_price_no_loops({'Apple': 2, 'Banana': 3}, [('Apple', 2), ('Banana', 1)])
returns 7.
Implement this function:
def total_price_no_loops(fruit_prices: dict, purchases) -> float:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: fruit_prices, purchases.
Input
{'Apple': 2, 'Banana': 3}
[('Apple', 2), ('Banana', 1)]
Output
7