[Tutor] Another Newbie question

Danny Laya danny_laya at yahoo.com
Tue Jun 24 12:23:41 CEST 2008


Hi I got some problem about writting convention in python. Some tutorial ask me to write this :

a = 1
s = 0
print 'Enter Numbers to add to the sum.'
print 'Enter 0 to quit.'
while a != 0:
    print 'Current Sum:', s
    a = int(raw_input('Number? '))
    s = s + a
print 'Total Sum =', s

And the response must be like this :

Enter Numbers to add to the sum.
Enter 0 to quit.
Current Sum: 0
Number? 200
Current Sum: 200
Number? -15.25
Current Sum: 184.75
Number? -151.85
Current Sum: 32.9
Number? 10.00
Current Sum: 42.9
Number? 0
Total Sum = 42.9

But when I write until this :

>>> a = 1
>>> s = 0
>>> print 'Enter Numbers to add the sum'

I press enter, and alas my python response me :
Enter Numbers to add the sum

It didn't want waiting me until I finish writing the rest.
I know there is some mistake about my writing convention, 
but what ??? Can you find it ??

But you know it's not finish,I ignore the error message and 
writng the rest, but until i write this:

>>> while a != 0:
....     print 'Current Sum:', s
....     a = int(raw_input('Number?'))
....     s = s+a
.... print 'Total Sum =', s

Oh, man... another error message :

  File "<stdin>", line 5
    print 'Total Sum =', s
        ^

Can you help me guys ??











       
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080624/3528c76a/attachment.htm>


More information about the Tutor mailing list