[Tutor] syntax error with a simple print command

David ldl08 at gmx.net
Thu Oct 2 16:35:12 CEST 2008


Dear list,

I was just trying the following code:

for i in range(0, 10, 2):
     print i
print "done!"

But I do get a syntax error, and I don't understand why:

 >>> for i in range(0, 10, 2):
...     print i
... print "done!"
   File "<stdin>", line 3
     print "done!"
         ^

As far as I understand, the for loop is executed, and once the loop is 
done Python exits the for loop and continues with the next command 
(print "done!").
Why is he complaining??

Many thanks for enlightening me!

David


More information about the Tutor mailing list