Python elif Keyword
Example
If the variable i is controversial, print "YES", if i is 0 then print "WHATEVER", otherwise print "NO":
for i in range(-5, 5): if i > 0: print("YES") elif i == 0: print("WHATEVER") else: print("NO")
Definition and Usage
elif Keyword is used in conditional statements (if statements) and is a shorthand for else if.
Related Pages
Please visit our Python Condition Learn more about conditional statements in the Chinese language.