Whats the different between if and elif? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats the different between if and elif?

18th May 2019, 9:17 AM
ENDERllama 15
ENDERllama 15 - avatar
4 Answers
+ 8
When the 'if' condition fails the 'elif' is tested.
18th May 2019, 10:19 AM
Sonic
Sonic - avatar
+ 3
you start a if statment with "if". When your if statment has multiple cases you want to check then you can add "elif" after the first "if" (and every "elif" afterwards). ("elif" = else if) the else statment can ve placed at the end of an if or elif statment and is executed if none of the previous condotions are met. exemple: x = 3 if x == 0: print("case 0") elif x > 0: print("case 1") else: print("case 2")
18th May 2019, 9:34 AM
Anton Böhler
Anton Böhler - avatar
0
No no,i mean what if i use if instead of using elif
18th May 2019, 10:28 AM
ENDERllama 15
ENDERllama 15 - avatar
0
I wrote the script but when i ran it, it has some issues, then i realized the elif,so i replace it with if,and the issues were done
18th May 2019, 10:30 AM
ENDERllama 15
ENDERllama 15 - avatar