0

Is statement

Why does the following code only print the 3? Num = 7 If num > 3: Print (“3”) If num < 5: Print (“5”) If num == 7: Print (“7”)

18th Jul 2018, 2:32 PM
Ryan Wesley Geller
Ryan Wesley Geller - avatar
3 RĂ©ponses
+ 4
Read the comments in the code below. It should help. https://code.sololearn.com/cSnguh075qYF/?ref=app
18th Jul 2018, 2:52 PM
cyk
cyk - avatar
+ 2
You have a syntax error. You’re missing ”:” after your if statements
18th Jul 2018, 2:40 PM
Toni Isotalo
Toni Isotalo - avatar
+ 1
The if statement is basically testing each if statment one by one, it doesn't test all together. That is why it only prints 3 because that first if statment is true, then the code moves on
19th Jul 2018, 12:21 AM
Paul Yan
Paul Yan - avatar