[Tutor] syntax error with a simple print command

Luke Paireepinart rabidpoobear at gmail.com
Thu Oct 2 16:42:21 CEST 2008

You are having an issue with the interpreter.  You can only submit 1 command
at a time to the interpreter.
Therefore, you need to finish your for loop and hit enter *twice* so that
the interpreter knows you're done with the loop.
The reason you're getting an error is it's trying to put your "print
'done!'" statement in the for loop, but it's not tabbed correctly.
it works like this because otherwise you could only have single-line for

On Thu, Oct 2, 2008 at 9:35 AM, David <ldl08 at gmx.net> wrote:

> 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
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081002/d175ae11/attachment.htm>

More information about the Tutor mailing list