Can elif be used to avoid nesting conditions | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 3

Can elif be used to avoid nesting conditions

29th Dec 2020, 6:48 PM
mofe_sanya
mofe_sanya - avatar
3 ответов
+ 5
Tioluwanimofe Adesanya elif is use for nesting conditions. if a > b: print (a) elif b > c: print (b) elif c > d: print (c) else: print (d)
29th Dec 2020, 7:08 PM
A͢J
A͢J - avatar
+ 3
It depends, if you have a if condition and only if it is true you want another if statement you couldn't avoid it with an elif statement. But if the first if condition doesn't have to be true you could use elif. But you can avoid nesting conditions by using connecting words like AND, OR..
29th Dec 2020, 6:56 PM
🔥EACY🔥
🔥EACY🔥 - avatar
+ 2
# yes. x=input() if x=="yes" : print("yes") elif x=="no": print("no") else: print("unknown")
29th Dec 2020, 7:08 PM
Ratnapal Shende
Ratnapal Shende - avatar