Tal Einat <taleinat <at> gmail.com> writes: > On Thu, Apr 1, 2010 at 10:06 PM, albert steine <albert.steine <at> live.se> wrote:
> > MY OPERATING SYSTEM IS WINDOWS VISTA HOME > > I HAVE INSTALLED PYTHON 2.6.4 > > WHEN I USE THE KEYWORDS else or elif in any programm it results > > to Syntax Error-invalid Syntax > > have any answer? > > thank-you > > > Are you placing a colon (":") after each "else" and "elif ..."? > > Are you making sure that the indentation of the "else" and "elif" are > the same as for the "if" statement, while indenting the inner code > block further? > In IDLE, the ">>> " prompt should be ignored when indenting, like this: >>> if condition: do_something() else: # <-- correct, although it looks strange do_something_else() If you tried to indent the "else:" to match the "if" like this: >>> if condition: do_something() else: do_something_else() or this: >>> if condition: do_something() else: do_something_else() you'll get and error because the "if" is actually in column 0 (remember, you should imagine the ">>> " isn't there!) while the "else:" is in column 4 or 8. Pressing Backspace before the "else:" should fix the indentation. Hope this helps. -- Beni Cherniavsky <c...@users.sf.net> _______________________________________________ IDLE-dev mailing list IDLE-dev@python.org http://mail.python.org/mailman/listinfo/idle-dev