Begniner Question

bruno modulix onurb at xiludom.gro
Tue Mar 22 04:54:10 EST 2005


Glen wrote:
> #!/usr/local/bin/python
> 
> import sys
> 
> print "1.\tDo Something"
> print "2.\tDo Something"
> print "3.\tDo Something"
> print "4.\tDo Something"
> print "5.\tDo Something"
> print "6.\tExit"
> 
> choice=raw_input("Please Enter Choice: ")
> 
> if int(choice)==1:
>    print "Here"
> else:
>    pass
> 
> if int(choice)==2:
> else:
>    pass
> 
(snip)
> 
> File "./Code.py", line 20
>    else:
>       ^
> IndentationError: expeted an indented block
> 
> What am I doing wrong?

Err... I'm not totally sure, but I think it could be possible that you 
perhaps should insert an indented block between lines 19 and 20 !-)

> Thank-you
You're welcome !-)

A bit more seriously, now... the construct:

if some_condition:
else:
   pass

is syntactically incorrect. Python expects an indented block between the 
'if' line and the 'else' line. If you don't have the needed code yet, 
you need to put a 'pass' here :

if some_condition:
   pass
else:
   pass

This will of course do nothing else than useless tests, but it will at 
least satisfy the language's rules.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for 
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list