+2

Control Structures Section 3 Question 3?

num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: print("7") Why would this not return "3" and "7" as num is greater than 3 but is also equal to 7. Does it work in a heirarchy?

10/14/2019 10:15:54 AM

Robert Hughes

3 Answers

New Answer

+2

Hi. Because the if statements are nested and 7>5 it prints only 3.

+1

It doesn't carry on with this final line because it stops at num < 5. I get it now. Thanks!

+1