
Ethan S. answered 04/03/20
Ivy League Computer Science and Math Tutor
Ui-Jeen Y.
asked 04/01/20The 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 (3 pizzas, one drink in total). Right now, I get the price of 3 pizzas and one drink minus the price of the 3 toppings (pepperoni, ham, anchovy).
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.
Thank you so much!
Ethan S. answered 04/03/20
Ivy League Computer Science and Math Tutor
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.