Skip to main content

python - example "for while loop" for addtion and substration

a = 1
s = 0
print('enter number to add to the sum')
print ('enter 0 to quit')

while a != 0:
    print('current sum', s)
    a = float(input('no.?     '))
    s = s + a
    print ('total sum =  ' ,s)