V
10

Just found a simple way to fix a bug that was driving me nuts for a week

I was stuck on a loop that kept running forever in my Python script, and after three tries, I added a simple print statement to show the counter each time. Seeing the numbers made me realize my condition was wrong, so I changed it and it worked. What's your go-to trick for finding bugs when you're stuck like that?
3 comments

Log in to join the discussion

Log In
3 Comments
finley_shah64
Honestly used to think debuggers were the only way to go, but print statements totally changed my mind. Sometimes you just need to see the numbers!
8
emma_baker61
My buddy did that once and it saved his whole project.
3
harris.andrew
Totally! My friend was trying to fix a weird loop for hours with a debugger. He finally just littered the code with prints to track a counter variable, like @finley_shah64 said. Turns out the value was jumping in a way the debugger steps totally missed. Seeing the raw output scroll by made the pattern obvious. He found a sneaky rounding error in like ten minutes. Sometimes the simple way is just faster.
5