[Tutor] Strange error
Remco Gerlich
scarblac@pino.selwerd.nl
Thu, 21 Feb 2002 15:28:38 +0100
On 0, Markus Wessel-Therhorn <markus-wt@gmx.de> wrote:
> Hi folks.
> I started learning python about a week ago and I found a strange problem.
> please look at this code:
>
> >>> a = 1
> >>> b = 2
> >>> if a > b:
> print "a > b"
> elif a < b:
>
> SyntaxError: invalid syntax
> >>>
>
> As the source for the error he points to the "elif". Is this problem somehow
> connected with IDLE or did i just make a misstake? i did it exactly like in
> the tutorial and I got no idea why it does not work.
> Would be very nice if someone could help me,
Probably an indentation error. You need to indent the "print" line, put a
few spaces before it to show that it is the block that follows the if:
command. The elif: line then should be at the same level as the if: command,
like
if a > b:
print "a > b"
elif a < b:
print "etc"
--
Remco Gerlich