💡
9
c/coding-for-beginners•the_iristhe_iris•20d ago

Got stuck on a loop for two hours at a coffee shop in Denver

I was trying to make a simple number game in Python and my while loop just wouldn't break. The guy next to me finally leaned over and said, 'You forgot to increment your counter, it's infinite.' Has anyone else had a tiny mistake that completely froze your brain?
3 comments

Log in to join the discussion

Log In
3 Comments
ruby_jones
ruby_jones19d ago
Ugh, that's the worst kind of bug! I started printing the counter variable inside the loop, just to watch it not change. It makes the problem so obvious, right? Like, your eyes just glaze over the missing line until you see the same number pop up ten times in a row.
10
andrewreed
andrewreed20d ago
Oh man, that's the worst feeling. I once spent an entire afternoon staring at a loop because I used a single equals sign in the condition instead of a double. What finally worked for me was just walking away for ten minutes and then reading the code out loud, super slow. It sounds silly but hearing it helps spot the little stuff your eyes just skip over.
6
knight.dylan
How many times have I done the exact same thing? I swear my brain just auto-fills that single equals sign now as a cruel joke. I once spent a whole day on a bug that was just a missing semicolon, felt like a total genius after that one. Reading code out loud is a legit move though, even if you sound a bit crazy doing it.
2