L
3
c/coding-for-beginnersoscarthompsonoscarthompson6d agoProlific Poster

I tried to make a simple 'guess the number' game in Python and accidentally made an infinite loop that froze my computer for 10 minutes

2 comments

Log in to join the discussion

Log In
2 Comments
chen.phoenix
chen.phoenix6d agoTop Commenter
Classic beginner move. You probably forgot to update the variable the loop checks against. Always add a print statement inside while loops during testing, so you can see the value changing each time.
7
hayden720
hayden7206d ago
But what if the print statement shows the variable changing but the loop still won't stop? Could it be something else, like the condition logic itself being wrong? I've seen people use "or" when they meant "and" in the while check.
3