Python Else If Statements

The elif is short for else if.it allows us to check for multiple expressions.if the condition for if is false,it checks the condition of the next elif block and so on in python.

Syntax

							
if test expression:
	body of if
elif test expression:
	body of elif
else:
	body of else
							
							

Example

							
a = 0;
if a > 0;
	print("Positive");
elif a == 0;
	print("Zero");
else:
	print("Negative");
							
							
Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!