Are elif and else the same | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Are elif and else the same

2nd Dec 2020, 12:12 PM
danayt Girmay
danayt Girmay - avatar
5 ответов
+ 6
"Else if" is used as "elif" in python it can be used as 'else if' also but for simplicity "elif" is used more frequently refer this for more https://www.sololearn.com/learn/Python/2278/
2nd Dec 2020, 12:39 PM
Piyush
Piyush - avatar
+ 4
Else does not need a condition but elif does.
2nd Dec 2020, 1:25 PM
Sonic
Sonic - avatar
+ 3
They are different.
4th Dec 2020, 8:29 AM
Sonic
Sonic - avatar
+ 2
danayt if is a first level of condition elif is middle level of condition and else is last level of condition means if 1st and middle level condition will be fail then else will be execute. Example: if(age < 18): print ("First level") elif(age > 18 and age < 60): print ("Middle level") else: print ("Last level")
2nd Dec 2020, 4:32 PM
A͢J
A͢J - avatar
+ 1
The last elif is similar,but followed by condition statements,so they are not the same exactly
2nd Dec 2020, 12:47 PM
yingSSS['book'=="本"]