+ 1

If statment contains if statement ... Only the 1if statement is considered right?

It doesnt matter how many if statements are there inside if statement , only the 1statement is taken ?

22nd Aug 2020, 7:18 AM
Ashish P Abraham
Ashish P Abraham - avatar
6 Respostas
+ 2
That's because of the indentation. Your code has returned True on the first query, so doesn't bother to read the rest of the indented code.
22nd Aug 2020, 7:35 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 6
Try running this code with adjusted indents num = 7 if num > 3: print("3") if num < 5: print("5") if num == 7: print("7")
22nd Aug 2020, 7:37 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
When I run the code, the output is 3 7
22nd Aug 2020, 7:35 AM
Pranav
Pranav - avatar
+ 1
For exmaple num = 7 If num > 3: Print("3") If num < 5: Print("5") If num == 7 Print("7")
22nd Aug 2020, 7:24 AM
Ashish P Abraham
Ashish P Abraham - avatar
+ 1
Ans could b 3 and 7 or 7 right ... But the output is only 3 .. why?
22nd Aug 2020, 7:25 AM
Ashish P Abraham
Ashish P Abraham - avatar