Simple if-else question

Joel Goldstick joel.goldstick at columbuswebmakers.com
Tue Sep 29 12:01:30 EDT 2009


Sandy wrote:
> Hi all,
> A simple and silly if-else question.
> I saw some code that has the following structure. My question is why
> else is used there though removing else
> has the same result. More important, is it not syntactically wrong :-(
> 
> for i in xrange(8):
>     if i < 4:
>         print i
> else:
>     print i
> 
> Cheers,
> dksr


else needs to be indented like if



More information about the Python-list mailing list