Python Language Else statement


Example

if condition:
    body
else:
    body

The else statement will execute it's body only if preceding conditional statements all evaluate to False.

if True:
    print "It is true!"
else:
    print "This won't get printed.."

# Output: It is true!

if False:
    print "This won't get printed.."
else:
    print "It is false!"

# Output: It is false!