Apr-14-2019, 09:15 AM
Create another function that calls
cost_calculator
with each pizza list and adds them up.def cost_calculator(in_list): cost_pizza = 0 cost_pizza += 13.00 pepperoni = ["pepperoni"] mushroom = ["mushroom"] olive = ["olive"] anchovy = ["anchovy"] ham = ["ham"] for item in in_list: if item in pepperoni: cost_pizza += 1.00 if item in mushroom: cost_pizza += .50 if item in olive: cost_pizza += .50 if item in anchovy: cost_pizza += 2.00 if item in ham: cost_pizza += 1.5 return cost_pizza def pizzas_cost(*pizzas): cost = 0 for pizza in pizzas: cost += cost_calculator(pizza) return cost print(pizzas_cost(["olive", "ham"], ["mushroom"]))
Output:28.5