Python elif Keyword
Used in conditional statements, same as else if. If the previous condition was not true, and
the next condition is true, execute the code in the elif
block. This is
shorthand for else if
.
Example
Python
Copy Code
total = 12 if total < 5: print("total is less than 5") elif total < 10: print("total is less than 10") else print("total is greater than or equal to 10")
Output
total is greater than or equal to 10