January 2019
Beginner
318 pages
8h 23m
English
The elif statement checks multiple statements for a true value. Whenever the value evaluates to true, that code block gets executed. Refer to the following syntax:
if test expression: if block statementselif test expression: elif block statementselse: else block statements
elif is short for else if. It allows us to check for multiple expressions. If the condition written in the if statement is false, then it will check the condition of the next elif block, and so on. If all of the conditions are false, the body of else is executed.
Only one block among the several if...elif...else blocks is executed according to the condition. The if block can have only one else block. But it can have multiple elif blocks. ...
Read now
Unlock full access