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 real
"Sudarshana Banerjee" 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
Hi: Thank you very much for the detailed reply. My problem is I know I am
doing the indentation wrong; but I cannot get it right in IDLE.
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
Thank you Karim.. the code is not actually part of anything... but is a
textbook example, literally (Python Power by Matt Telles).
On Wed, Aug 11, 2010 at 9:59 AM, Karim wrote:
>
> Hello,
>
> This code works for me:
>
>
> >>> x=3
> >>> if x==0:
> ... print "x is 0"
> ... elif x&1 ==1:
> ...
Thank you Adam.
On Tue, Aug 10, 2010 at 7:03 PM, Adam Bark wrote:
> On 11/08/10 02:34, Sudarshana Banerjee wrote:
>
> Hi: I am trying to teach myself Python, and am stuck at the indentation
> with the elif statement.
>
> This is what I am trying to type (as copied from the textbook):
>
> x=3
>
Hello,
This code works for me:
>>> x=3
>>> if x==0:
... print "x is 0"
... elif x&1 ==1:
... print "x is a odd number"
... elif x&1==0:
... print "x is a even number"
...
x is a odd number
So I think you copied by error the string '-- Line 6' in you example
given that has nothing
You need to check the indentation properly.
In this case, elif has to be on the same indentation level with if. I
should think so.
If you're working straight from the python interactive console, like I
think you're doing, you need to manually do the indentation thing by
yourself.
First, I don't und
On 11/08/10 02:34, Sudarshana Banerjee wrote:
Hi: I am trying to teach myself Python, and am stuck at the
indentation with the elif statement.
This is what I am trying to type (as copied from the textbook):
x=3
if x==0:
print "x is 0"
elif x&1 ==1:
print "x is a odd number"
elif x&1==0