20
Just realized my loop was running forever because I forgot a simple thing
I was messing with a while loop in Python and it just kept going, turns out I never incremented my counter variable. Has anyone else had a brain freeze moment like that with loops?
3 comments
Log in to join the discussion
Log In3 Comments
mitchell.jessica1mo ago
Spent a solid ten minutes staring at my screen because a for loop wouldn't end. I was iterating over a list but accidentally appending to it inside the loop, so it just kept growing forever. Felt like a real genius that day.
6
shanek621mo ago
Classic @mitchell.jessica, building a list that never quits.
4
theahart1mo ago
Actually, infinite loops can be a useful tool. I once set up a background process that kept adding timestamps to a list, and it ran perfectly until I needed the data. It was a simple way to log events without managing file writes. @mitchell.jessica's situation sounds like a good way to stress test memory limits. Sometimes you learn more from a program that runs too long than one that ends too soon.
2