"WM." <[email protected]> wrote
>>> i = 5
>>> j = 7
>>> if i <= j:
print 'nudge, nudge'
          else:

  File "<pyshell#8>", line 3
    else:
   ^
IndentationError: unexpected indent

Running in IDLE, all is well until "else:". IDLE seems perplexed

This is, in my view, a long standing bug in IDLE. It doesn't show indentation properly in the shell window. If possible I'd suggest you try using Pythonwin
or PyCrust or IPython or any of the other 3rd party shell windows.

If you use them they will typically insert three dots as a secondary prompt
which keeps everything lined up properly.

The else should align with the if but in Idle it has to align to the left margin
because the if is only indented due to >>> prompt! This is confusing,
and effectively a bug in my opinion. Your if statement in IDLE should look like:

if i <= j:
   print 'nudge, nudge'
else:

ie the print should be indented and the else not be.
Without the >>> it becomes sane:

if i <= j:
   print 'nudge, nudge'
else:


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to