I need to get the size of a pizza, and return it. I am using a while loop (not sure if I need to use something else?) and the problem is, even when I enter a valid choice, it prompts me to enter the size again instead of returning the size.
def pizzaSize():
print("What size of pizza do you want\n (s)mall, (m)edium, or (l)arge?\n")
size = input()
while size != 'l' and size != 'm' and size != 's':
print("ERROR invalid pizza size")
size = input()
return size`
I am pretty new to this, just started my first programming class.
Edit:
I believe what is causing my issue is another piece of the code. I was calling the function multiple times and causing it to repeat. Now I have a separate issue. How do I take what is returned from a previous function and use it in a later one without calling the previous function?
def pizzaPrice():
if size == "s":
cost = 9 + .50 * numTop
elif size == "m":
cost = 11 + .75 * numTop
elif size == "l":
cost = 13 + 1 * numTop
return cost
numTop is what is returned in a previous function. How do I get that in the pizzaPrice function? It says it is not defined, but when I define it as the function, it calls that function.