0
What's wrong in this
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("Okay") Please tell in deatil
4 Réponses
+ 1
Kindly use relevant tags
0
try using elif instead of else if.
0
Hi eco fico. There are several problem in your code...
1. You are making the code more COMPLICATED to understand by not using ELIF instead of such a nested if and else structure.
2. This program is printing okay as it should, because according to the conditions -
a. if num == 5 returns false
b. then in the else, if num == 11 returns false
c. then in the "else of else", if num "!=" 7 returns false since it is 7
d. prints "okay" in the ELSE OF ELSE OF ELSE.
At last, dear make programs with elif and less complicated...