If statement output | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

If statement output

num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: print("7") please tell me why output of this code is 3.. i don't get it :/

26th Jun 2019, 12:20 PM
Dato InLostPlace
Dato InLostPlace - avatar
2 Answers
+ 9
This is an example of nested if statement......... See carefully that the second condition is not executed , so the if num == 7 statement doesn't run at all ........ Hope it helps..........
26th Jun 2019, 12:41 PM
Shadow Ninja[#Inactive]
Shadow Ninja[#Inactive] - avatar
0
Thank you so much ^^
26th Jun 2019, 1:12 PM
Dato InLostPlace
Dato InLostPlace - avatar