What's the difference between elif and else | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the difference between elif and else

Or are they the same

22nd May 2019, 1:18 PM
Mike Harris
Mike Harris - avatar
3 Answers
+ 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
22nd May 2019, 1:20 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 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
22nd May 2019, 1:24 PM
Russ
Russ - avatar
+ 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.
22nd May 2019, 2:57 PM
Md Daniyal
Md Daniyal - avatar