+ 1
if statements
Last one question in this part, why in explanation before output is 2 print, mean "Bigger than 5 Between 5 and 47", but when num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: print("7") output is 3, not 37 ?
3 odpowiedzi
+ 1
It's because the "if num == 7:" is within the scope of the "if num < 5:"
Since "if num < 5:" is false it cant check "if num ==7"
Simply do
num = 7
if num > 3:
print("3")
if num<5:
print("5")
if num == 7:
print("7")
#The if num < 5 and if num == 7 should be indented the same amount, it should line up the two if statements
0
oh i just took a deeper look and i can explain why its 37
its bigger than 3 and equal 7. 5 doesnt print cuz its not less than 5
0
Saved me time!