Counting strings in positional arguments python (order cost calculator problem)
The goal is to calculate the cost of a order at a pizza shop. For example:
cost([ ], ["pepperoni"], ["ham", "anchovy], drinks = ["small"])
should calculate the price of one plain pizza, one pizza with pepperoni toppings, one pizza with ham and anchovy toppings, and one drink (4 pizzas, one drink in total). The pizzas are arbitrary positional arguments but the drinks are named orders (keyword arguments). I was able to figure out how to count the number of positional arguments (pizzas) but I cannot figure out how to account for the price of the toppings.
I am confused about how to deal with positional arguments in this case: pizza. I am mainly confused about how to account for the toppings. I thought *pizza would allow me to access cost(pizza) as a list, but it does not work.
This is what I have so far.
def cost(*pizza, drinks):
for your_drinks in drinks:
drinks_cost = drinks.count("small")*2
pizza_cost = len(pizza)*13
#this for loop does not behave the way I want it to.
for toppings in pizza:
toppings = pizza.count("pepperoni")*1 + pizza.count("anchovy")*2 + pizza.count("ham")*1.5
total = drinks_cost + toppings + pizza cost