T
21

I spent 6 hours yesterday trying to figure out why my loop wouldn't stop.

I was making a simple number guessing game in Python and I forgot to update the variable inside the while loop, so it just kept asking forever.
3 comments

Log in to join the discussion

Log In
3 Comments
joseph_hart
Oh man, I feel that! I started adding a simple print statement right before the loop condition to check the variable each time. Seeing it stuck on the same number made the problem obvious in like two minutes. It saves me so much headache now.
3
the_piper
the_piper2mo ago
Six hours? That's brutal. We've all been there staring at an infinite loop.
2
nina180
nina1802d ago
Print statements are just treating the symptom @the_piper, the real fix is understanding why your condition logic is wrong.
5