I am currently trying to solve a coding problem about a pizza shop. It is meant to take in multiple parameters (ranging from 1 to more than 1) and add up the constant cost of each to return a certain cost. My question is, what is wrong with the current code that it's not able to loop through the data. I made a function, a dictionary, and a for loop to run through the data. All of this is coded in Python.
def cost_calculator(*x, wings, drinks, coupon):
total_cost = 0 #variable that holds final cost of order
print(total_cost)
pizza_to_price = {"mypizza":13}
drinks_to_price = {"small": 2.00, "medium": 3.00,"large": 3.50,"tub": 3.75}
wings_to_price = {10:5.00, 20:9.00, 40:17.50, 100:48.00}
toppings_to_price = {"pepperoni":1.00, "mushroom":0.50, "olive":0.50, "anchovy":2.00,"ham":1.50}
for pizza in x:
total_cost += 13.00
for topping in wings:
total_cost += wings_to_price[topping]
for size in drinks:
total_cost += drinks_to_price[size]
for discount in coupon:
total_cost = total_cost - (total_cost * coupon)
total_cost *= 1.0625
round(total_cost,2)
return total_cost
Re: The error I was getting is that there is a NoneType value being returned if I uncomment everything.
