Python If Elif
Elif
The elif keyword is pythons way of saying "if the previous conditions were not true, then try this condition".
Example
a = 33
b = 33
if b> a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
Try it Yourself »
b = 33
if b> a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
In this example a is equal to b, so the first condition is not true, but the elif condition is true, so we print to screen that "a and b are equal".
Related Pages
Python If...Else Tutorial If statement If Indentation Else Shorthand If Shorthand If Else If AND If OR If NOT Nested If The pass keyword in If