T
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?
2 comments

Log in to join the discussion

Log In
2 Comments
milam42
milam4224d 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
tessa922
tessa92224d ago
Totally did that with my phone while holding it once, @milam42.
3