[Tutor] else syntax error problem
Mon, 05 Jun 2000 21:38:57 +0000 (GMT)
I am having the strangest problem here.
I am completely new to python (and programming, really) and am happily
working my way through the van Laningham book. In the spirit of learning
by doing rather than just reading I have been typing in his excellent
screen shots [could be a tad larger for easier reading, mind you] and I've
come unstuck on the ones to do with else and elif. Here's what I see in my
*Python Shell* window when working through fig 4.8 which is an amusing
little number that does a rocket countdown leading to Blastoff!
>>> for i in range(10,-1,-1):
if i != 0:
SyntaxError: invalid syntax
What should continue after else is...
What it looks like is that the part of python that handles else and elif
is missing - but that's daft, isn't it? Is it significant that that else:
below print i isn't hanging indented to be back underneath the if 2 lines
If it helps, I'm using Python 1.5.2 on Mandrake Linux 7.0.
Many thanks to anyone who can penetrate the fog for me on this one.