[Tutor] Indentation woes in elif statement
joel.goldstick at gmail.com
Wed Aug 11 14:13:55 CEST 2010
On Tue, Aug 10, 2010 at 9:11 PM, rara avis <fried.sigmund at gmail.com> wrote:
> Hi: I am trying to teach myself Python, and am stuck at the indentation
> with the elif statement.
> This is what I am trying to type:
> if x==0:
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
x = 3
if x == 0:
print 'x == 0'
elif x != 0:
print 'x != 0'
x != 0
The block of code under 'if x...' is indented. Most people use 4 spaces.
You can use any number of spaces, but you need to be consistant
The elif indentation must match its matching if statement. In this case
neither are indented
The block which executes under the elif is indented to the same level as
that under the original if
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor