[Tutor] syntax error with a simple print command
Luke Paireepinart
rabidpoobear at gmail.com
Thu Oct 2 16:43:41 CEST 2008
note that I meant it's not tabbed correctly *to be part of the for loop*.
On Thu, Oct 2, 2008 at 9:42 AM, Luke Paireepinart <rabidpoobear at gmail.com>wrote:
> 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 <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/b172cadf/attachment.htm>
More information about the Tutor
mailing list