a = int(input("How many pizza would you like to order? ")) #line 1
def count_ordered_pizza():
if a==0:
print("Okay see u next time!")
elif a==1:
print(str(a)+ " pizza ordered.")
elif a>1:
print(str(a)+ " pizzas ordered.")
else:
print("Sorry that's impossible")
def reorder():
user_said= str(input('Do you wish to order again? State Y/N. '))
while user_said != "N":
a = int(input("How many pizza would you like to order? ")) #line 16
count_ordered_pizza()
reorder()
print('Bye!')
If I execute this, the a
in reorder()
function (line 16), doesn't replace the a
in count_ordered_pizza()
function (line 1). Why is that?
I thought it could replace them since the variable has been overwritten, but if i do this:
def reorder():
user_said= str(input('Do you wish to order again? State Y/N. '))
while user_said != "N":
a = int(input("How many pizza would you like to order? ")) #line 16
if a==0:
print("Okay see u next time!")
elif a==1:
print(str(a)+ " pizza ordered.")
elif a>1:
print(str(a)+ " pizzas ordered.")
else:
print("Sorry that's impossible")
reorder()
print('Bye!')
It shows the correct value. Can someone help me with this please? Thank you in advance!