9
My first Python loop printed the same thing 10,000 times
I was trying to make a simple script that would say 'Hello' a few times, but I messed up the condition. Instead of stopping at 10, it just kept going. I looked away for a minute and came back to a terminal window filled with nothing but 'Hello'. It took me a solid five minutes to figure out I had typed 'while x > 0' instead of 'while x < 10'. Has anyone else had a simple typo cause a total meltdown like that?
3 comments
Log in to join the discussion
Log In3 Comments
christopherross1mo ago
My friend's infinite loop crashed a whole lab computer once.
2
adams.vera1mo ago
Used to think infinite loops just ate up CPU time. That story about the lab computer changed my mind. Turns out they can actually lock things up hard if they go wild. Makes you respect the old "break" statement a bit more.
4
piperr581mo ago
Oh man, that's the scary part. It's not just the CPU. A runaway loop can hog all the memory too, or freeze up the whole system waiting on something that never comes. I saw a script stuck in a while-true eat all the RAM once, killed every other program. Makes you double-check your exit conditions for real.
8