Python IF condition | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python IF condition

What is the output of this code? num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: print("7") shouldn't that give 2 outputs? 3 and 7?

5th Nov 2019, 3:29 PM
Adham Khaled
Adham Khaled - avatar
1 Answer
+ 2
No. Firstly it asks if num > 3 and it is true. Then it asks if num < 5, and it is false. Because the third if is inside the second if, it is not going to run. So, the only output is 3
5th Nov 2019, 3:42 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar