Friday, November 19, 2021

Python WHILE CONTINUE and BREAK Example

# CONTINUE to allow user to withdraw and display balance until value 0 is used to exit(BREAK)

 balance=10000;
while True:
    print('****Continue example *****')
    print('Enter amount to withdraw :')
    val=input()
    if(int(val)<0):
        continue
    elif(int(val)==0):
        print('Exiting program')
        break
    else:
        balance=balance-int(val)
        print('balance is now :'+str(balance))

print('****End of balance****')

No comments:

Post a Comment

Please add value. Sharing is caring