[Tutor] elif statement

Sudarshana Banerjee sudarshana.b at gmail.com
Sat Aug 14 04:01:02 CEST 2010


Hi Alan: Yay! I pressed Enter after the print, and then delete. Which
brought the cursor back to the starting position at the beginning of the
line, and no more elif syntax errors. This is good to know. Thank you very
much.

I also took the liberty of checking out your computing website. It is really
helpful; and I have added it to my bookmarks.

Thanks a ton!

Sudarshana.

On Fri, Aug 13, 2010 at 1:27 AM, Alan Gauld <alan.gauld at btinternet.com>wrote:

>
> "Sudarshana Banerjee" <sudarshana.b at gmail.com> wrote
>
>
>  Could you take a look at this please:
>>
>>> x=3
>>>>> if x==0:
>>>>>
>>>> print "x is 0"
>>
>>  elif x&1==1:
>>>>>
>>>> SyntaxError: invalid syntax
>>
>> See, the moment I am pressing Enter the >>> is coming.. not ...
>>
>
> IDLE doesn't give you a ... prompt it gives you spaces.
> So you mistake is that ypu are hitting Enter after your print line. It
> needs to look like:
>
>
>  x=3
>>>> if x==0:
>>>>
>>>   print "x is 0"
> elif x&1==1:
>   print....
>
> Which looks horrible and I wish Idle were fixed so it didn't do this.
> I keep meaning to try and find a way to patch it myself!
>
>
> Essentially you need to ignore the >>> offset in the if line.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100813/21d0fb32/attachment.html>


More information about the Tutor mailing list