0
Why is not working? please with explanations
num = 7 if num == 5: print("number is 5") else: if num == 11: print("number is 11") else: if num == 7: print("number is 7") else: print("number is ont anything from 7.11.5")
3 ответов
+ 3
prefer notation like
if num == 7:
print....
elif num == 5:
print ....
elif num == 11:
print ....
else:
none of previous case
+ 2
you canot have multiple else for one if. but you can have elif wich is a else + if statement.
0
The nested if statements were obscuring the result, try this:
num = 7
if num == 5:
print("number is 5")
elif num == 11:
print("number is 11")
elif num == 7:
print("number is 7")
else:
print("number is not anything from 7.11.5")