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
loops!

On Thu, Oct 2, 2008 at 9:35 AM, David <[EMAIL PROTECTED]> 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@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to