[Tutor] If Elif

Xavier Combelle xcombelle at kedros.com
Fri Feb 20 03:57:12 EST 2004


big steve a écrit :

> ** 
> *I am having a problem getting the IF/ELIF to cooperate with me. I am 
> using a sample from:      Learn to program  By Alan Gauld. I keep 
> getting this msg:    *
>  
> *IndentationError: unindent does not match any outer indentation level 
> (<pyshell#3>, line 3)*
>  
> **
> *
>   But When I don't indent I get:
>                                   SyntaxError: invalid syntax
> _________________________________________________________________________________*
> * *
> *This is the sample I was trying:*
> * *
> *value = 100
> if value > 10:
>     print 'This is OK'
> elif value > 50:      #This is where I get that msg (IndentationError)
>     print "Whoops, this is never seen'
> else
>     print ' nor is this'*
> * *
> *______________________________________________________________________________*
> * *
> * *
> * *
> *  I CAN simply us the If format and all works it is just a little 
> confusing!
>    Could it be that I have mesed with my default sttings on 
> Indentation? Or am I just to thick to see the obvious?  any help ?  
> Thanks  Steve Hulett*
>
>------------------------------------------------------------------------
>
>  
>
When I tried to execute the script I found two mistakes

"Whoops, this is never seen'
which begin with a double quote and end with simple quote

*else
which don't end with a colon  (should be else:)
*
but I did not found indentation error


I suspect that the else is not above the if
(It seems can be happen if you merge tabs and spaces for example)




More information about the Tutor mailing list