Why doesn't my last two ifs activate? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why doesn't my last two ifs activate?

x = 3 while x <= 70: print(x) x +=2 if x == 25: print("Stop for a while") if x == 50: print("Almost there") if x == 68: print("At 99%")

14th Apr 2020, 5:17 AM
Tonje
Tonje - avatar
2 Answers
+ 2
You are adding odd with even, and that always result with an odd number. Therefore 50 and 68 will never come.
14th Apr 2020, 5:29 AM
Tricker
+ 2
3+2+2+2... x will be 49, then 51, it will never be 50.
14th Apr 2020, 11:33 AM
Fernando Pozzetti
Fernando Pozzetti - avatar