if-elif-else statement
The statement consists of the following parts:
if
The if part contains the if keyword, a conditional expression and the block executed if condition is TRUE. If the condition is FALSE, control passes to the next part elif.
elif
The elif part contains the elif keyword, a conditional expression and the block executed if condition is TRUE. The statement is likely to contain some elif parts followed one after another.
else
The else part contains the else keyword and the block executed if the condition of the if part as well as the condition of all elif parts are FALSE.
The elif and the else operators are optional.
The value of a conditional expression must be numeric. The value is TRUE if it is nonzero.
//if
if a == 1
{
b = 10
}
//if and else
if a == 10 && b > 20 : b = 10
else
{ b = 0 }
//if elif else
if a == b+10
{
...
b = 10
}
elif a > 2 { b = 100 }
elif a != 1 || b == 32 : b=1000
else : b = 0