statements operators functions string methods set methods tuple methods dict methods file methods list methods exceptions exception types comprehensions multidimensionals os lambdas subprocess
Intro to Python

Session 1 Session 2 Session 3 Session 4 Session 5 Session 6 Session 7 Session 8 Session 9




pythonreference.com

search statements, functions, methods, exceptions*

hide categories

'else' statement
if all prior if/elif tests in this chain are False, enter the block
var = 3
if var > 0:
    print('higher')
elif var < 0:
    print('lower')

else:
    print('equal')

print('continuing...')
initialize int if int is greater than 0: print str otherwise if int is less than 0: print str otherwise: print
1) if all if and elif tests in the chain above this statement are False, enter the block 2) when the end of the block is reached, continue to the next line