+ 1
Final Q -- why doesn't it also print 7?
Hi, I'm curious about the final question in the "if statement" section. In one of the previous if-statements, it printed more than one result: num = 12 if num > 5: print("Bigger than 5") if num <=47: print("Between 5 and 47") Result: >>> Bigger than 5 Between 5 and 47 >>> The last question was as follows: num = 7 if num > 3: print("3") if num < 5: print("5") if num ==7: print("7") I understand why it prints 3, but why doesn't it also print 7? The first code printed two results, so why not this one?
1 Respuesta
+ 4
look at the indentations
'if num==7' is enclose at the previous if statement like that
if num<5{
...
if num<7
....
}
indentations works on enclosing statements