Serious question, how did it take me 3 days to learn the print statement trick for finding bugs? | Coding For Beginners - Freelance Forum - The Community for Independent Professionals
Serious question, how did it take me 3 days to learn the print statement trick for finding bugs?
I was stuck on a while loop in my Python class at 2am, dropping print statements after every line like a caveman, when my roommate walked by and said just print the variable before and after the loop, and it freaking worked instantly, so now I'm wondering what other obvious beginner tricks am I missing?
Wait, your roommate said to print the variable before AND after the loop? Like both ends, not just inside it? I've been doing the caveman thing too but only putting prints inside the loop, and half the time I can't tell if the problem is the loop never running at all or the condition being wrong or the variable never changing. So do you print the starting value, then the ending value, and that tells you which one broke? I'm asking because my for loops keep giving me weird output and I bet it's the same thing. What did the two prints actually show you that the inside ones didn't?