[Tutor] Problem with "elif"

Andrei Kulakov ak@silmarill.org
Sat, 24 Nov 2001 18:06:17 -0500


On Sat, Nov 24, 2001 at 09:14:20PM +0100, Pjotr wrote:
> Hello!
> I started learning Python, using Python 2.1.1 and Ivan Van Laningham's
> book "Teach yoursefl Python...".  I have a problem with instruction
> "elif":
> >>> y = 1900
> >>> leap = "no"
> >>> if y % 400 == 0 :
>         leap = "yes"
>     elif y % 100 == 0 :
>             
> IndentationError: unindent does not match any outer indentation level (line 3)
> >>> 
> 
> What's up? This example is from Laningham's book and everything should
> be OK. Please help me!

Here's how it looks here:

>>> y = 1900
>>> leap = "no"
>>> if y % 400 == 0 :
...  leap = "yes"
... elif y % 100 == 0 :
...  leap = "no"
... 
>>> leap
'no'
>>> 

When you hit enter after the first ':', interpreter should print three
dots to indicate that you're entering a block.. or what's it called.
Anyway, I'm not quite sure what's wrong on your end but note that by
convention, you shouldn't leave a space before the ':'. It don't cause
an error but this is a matter of good style..

> -- 
> Best regards
> Pjotr
> ________________________
> &&& pjotr@poland.com &&&
> 
> 
> 
> ---
> "W pustyni i w puszczy" juz  na kasetach VIDEO. Podaruj swojemu dziecku przygode !
> http://www.w-pustyni-i-w-puszczy.pl
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org