problem with the if statement and elif

Arne Koewing ark at gmx.net
Sat Jan 18 15:56:29 EST 2003


ciouded0ne at aol.com (CIouded 0ne) writes:

> no im not copying and pasting. i have tryed that before but now all
> i do is just look at it and copy it down manually but here is an
> example that doesnt work for me.
>
>
> x = raw_input("Enter a number? ")
> Enter a number? 0
> if x == 0:
> print "Hey good job"
> elif x > 0:
> print "Bad job"
> else: 
> print "Oh well"
>
you must indent the blocks!

your example should be:

x = raw_input("Enter a number? ")
if x == 0:
    print "Hey good job"
elif x > 0:
    print "Bad job"
else: 
    print "Oh well"

in python the level of indention 'forms' the blocks... 





More information about the Python-list mailing list