[Tutor] elif statement
Alan Gauld
alan.gauld at btinternet.com
Fri Aug 13 10:27:29 CEST 2010
"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/
More information about the Tutor
mailing list