elif Statement
Sometimes, the programmer may want to evaluate more than one condition. This can be done using an elif statement.
An elif statement works on the following principle:
- Execute the block of code inside the
ifstatement if the initial expression evaluates toTrue. After execution, return to the code outside theifblock. - Execute the block of code inside the first
elifstatement if the expression inside it evaluates toTrue. After execution, return to the code outside theifblock. - Execute the block of code inside the second
elifstatement if the expression inside it evaluates toTrue. After execution, return to the code outside theifblock.- ...
- Execute the block of code inside the nth
elifstatement if the expression inside it evaluates toTrue. After execution, return to the code outside theifblock. - Execute the block of code inside the
elsestatement if none of the expressions evaluate toTrue. After execution, return to the code outside theifblock.

Example:
num = 0
if (num < 0):
print("Number is negative.")
elif (num == 0):
print("Number is Zero.")
else:
print("Number is positive.")Output:
Number is Zero.