0
What's the difference between elif and else
Or are they the same
3 ответов
+ 7
elif - - else if, it's just an else with an if statement, instead of you writing else if again you can just write elif
+ 2
if x:
code executed only if x is true
elif y:
code executed only if x is false but y is true
else:
code executed only if x and y are both false
+ 1
The elif (short for else if) statement is a shortcut to use when chaining if and else statements.
A series of if elif statements can have a final else block, which is called if none of the if or elif expressions is True.