+ 3
Can elif be used to avoid nesting conditions
3 Respuestas
+ 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)
+ 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..
+ 2
# yes.
x=input()
if x=="yes" :
print("yes")
elif x=="no":
print("no")
else:
print("unknown")