+ 1

I don't understand the output of the following code. Anyone who can help me with it?

num = 7 if num > 3: print("3") if num < 5: print("5") if num == 7: print("7")

22nd Apr 2022, 1:31 PM
Aaradhya
Aaradhya - avatar
6 Answers
+ 2
Also, don't use a single space for indents. It can get real confusing. Use tab or at least 2 spaces
22nd Apr 2022, 1:40 PM
Slick
Slick - avatar
+ 2
Ooohk so we don't go to look for it until previous if statement is true... Thank you for ur help
22nd Apr 2022, 1:40 PM
Aaradhya
Aaradhya - avatar
+ 1
3 Cause those if statements are inside of eachother. Indentation matters
22nd Apr 2022, 1:33 PM
Slick
Slick - avatar
+ 1
Because you indented the other if statements inside of eachother. 7 will only print if the number provided is greater than 3 and less than 5. When the number is 7, that will never happen.
22nd Apr 2022, 1:39 PM
Slick
Slick - avatar
0
I used a single space in the code (for identation), the output i get is 3 but why cannot it be 7
22nd Apr 2022, 1:37 PM
Aaradhya
Aaradhya - avatar
- 1
Bitta misol bor edi korip berasizma
24th Apr 2022, 9:50 AM
Zayniddin Isroilov