21
Got stuck on a simple loop for two hours at a library coding workshop
I was at a free Python workshop at the Denver Public Library last Saturday, and we were doing a basic number guessing game. I wrote a while loop that was supposed to run until the guess was correct, but I forgot to update the guess variable inside the loop. The instructor walked by after I'd been staring at my screen for what felt like forever, pointed at one line, and said 'Your loop can't read your mind, you gotta tell it the guess changed.' Felt so dumb but it finally clicked. Now I double-check my variable updates before I even run the code. Anyone else have a moment like that where a tiny mistake ate up a huge chunk of time?
3 comments
Log in to join the discussion
Log In3 Comments
milam422mo ago
Ever notice how this happens with way more than just code? I'll put my keys down in a weird spot, then spend ten minutes looking for them while they're just sitting on the washing machine. Or I'll keep checking the same empty fridge, like the food will magically appear if I look again, instead of just writing it on the grocery list. It's like our brains get stuck in a loop too, doing the same check over and over without updating the info. Your story about the variable is the perfect digital version of that.
2
tessa9222mo ago
Totally did that with my phone while holding it once, @milam42.
3
terry_hayes181mo ago
Honestly that line about checking the empty fridge is so real. My friend once spent an hour trying to fix a broken lamp, only to realize he never plugged it back in after moving it. It's wild how we all get stuck in those mental loops sometimes.
-2