+ 5

In if statement 7==7 also true then that value also be printed... But it accepts only the first value.. Its wrong

13th Sep 2016, 5:41 PM
Vishnu Kumar P.S.
Vishnu Kumar P.S. - avatar
6 Respuestas
+ 22
it's because the third if is nested within the second one, which is false! so the third isn't even read
18th Sep 2016, 3:51 PM
Julie Kang
Julie Kang - avatar
+ 5
Mind the indentation. Those are nested if. What you say would be true if the program was: num = 7; if num > 3: print("3") if num < 5: print("5") if num==7: print("7")
13th Sep 2016, 5:47 PM
Zen
Zen - avatar
+ 1
It executed line by line so that last if should also be printed na
13th Sep 2016, 5:47 PM
Vishnu Kumar P.S.
Vishnu Kumar P.S. - avatar
+ 1
agree with Julie. when you change the 5 to a 9 you get 3 9 7 Then all the statements are considered
24th Dec 2016, 3:51 PM
luke Evans
luke Evans - avatar
0
In nested statement num=3 if num<7: print("1") if num>5: print("2") if num<=3: print ("3") And is :1. why not 1&3.
21st Nov 2016, 1:55 PM
Sree Latha
Sree Latha - avatar
0
i did't Understanding
19th Dec 2016, 2:10 PM
Ibra