how do I update a balance of the variable constanta
def menu():
balance = float(100.0)
print (" 1.Balance 2.Draw ")
ask = ('choose')
if (ask == '1'):
print ("Your Balance is {0}".format, balance)
ask2 = input('do you want go back to menu ?')
if (ask2 == 'y'):
menu()
else:
sys.exit()
elif (ask == '2'):
draw = input("How Much : ")
new_balance = (balance - draw)
balance = new_balance
print (balance)
ask2 = input('do you want go back to menu ?')
if (ask2 == 'y'):
menu()
else:
sys.exit()
So when my first input is 1 the output is 100.0, then I go back to menu and the second input I choose 2 with the draw input of 50 so the new_balance is 50. I then go back to menu() and choose input 1 but the balance variable is still 100.0.
How To Update Variable Until balance = 0
whileloop?