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")

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".


Else

The else keyword catches anything which isn't caught by the preceding conditions.

Example

a = 200

b = 33

if b > a:

 print("b is greater than a")

elif a == b:

 print("a and b are equal")

else:

 print("a is greater than b")

Jay Kakadiya

Jay Kakadiya Creator

I am a computer field, & i am Web developer.

Suggested Creators

Jay Kakadiya