Why doesn’t it stop? Using “or” | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why doesn’t it stop? Using “or”

I can’t figure this out. The code shown below stops at 0. If you change b to “b=-1”, it’s an infinite loop! I added the break so it would t freeze up my program. So why doesn’t the loop keep going when b is 0 also?? Why does it stop? Why wouldnt it stop if b is -1? Help!!!! a=5 b=0 while(a or b): a-=1 if a == -10: break print(a) print(a)

3rd May 2019, 2:48 PM
Beau Tooley
Beau Tooley - avatar
1 Answer
+ 6
-1 is True. The only number that is False is 0
3rd May 2019, 2:54 PM
Anna
Anna - avatar