dimanche 20 décembre 2015

Python indentation semantics

I just have a very simple question, and just need to confirm that I got the point.

Say that we have the following Python code snippet:

x = 0
if x == 5:
    print 'x is equal to 5'
else:
    print 'x is not equal to 5'

print 'program done'

If we indent the statement print 'program done' as follows:

else:
    print 'x is not equal to 5'
    print 'program done'

Will print 'program done' in this case be part of the block code associated with else?

Aucun commentaire:

Enregistrer un commentaire