Help on a summative formula

Ahimsa ahimsa at inext.co.za
Tue Jan 1 15:47:13 EST 2002


Thanks for the input folks.
I found a way to make it work. With a bit of tweaking I may be able to get
it to cut off an input that would exceed 100. But what the heck: this is my
very first code that does something more than say 'Hello, World!'. Thanks
for indulging me in this birth  ;-)>
For comments (constructive please) this is it.
Thanks
Andrew
______________________
# Running total of user inputs until the sum exceeds or is equal to 100.
a = 1
s = 0
print 'Enter a number to add till you reach 100.'
print 'If you wanna quit, just enter 0.'

while a != 0:
    print 'Current sum is ',s

    a = input('Number? ')
    s = s + a
    if s >= 100:
        print 'Thank you.'
        print 'Total Sum was ',s
        print 'Bye.'
        break
    else:
        print 'And again ...?'
print 'Have a nice day now!'
__________________________





More information about the Python-list mailing list