+ 2

31[python]

if 4<2 : print ("yes") if 3>1: print (1) if 1==1 print (2) Please explain while the result of this code is no output

15th Jun 2020, 8:48 AM
Oladeji
2 Answers
+ 6
Look at the expression at the first line ... if 4 < 2: Here you know it evaluates to False because 4 is greater than 2. Then the block under the `if` statement will be ignored because the condition evaluation yields False. You then get that "No output" message because there's nothing printed. All the calls to print() function are located under the `if` branch block.
15th Jun 2020, 9:16 AM
Ipang