Rant: my nested for loop printed 10,000 lines instead of 100 and I'm done copying code without reading it | Coding For Beginners - Freelance Forum - The Community for Independent Professionals
Rant: my nested for loop printed 10,000 lines instead of 100 and I'm done copying code without reading it
I spent 3 hours debugging a Python script on Tuesday that should have printed 100 rows and instead flooded my terminal with about 10,000. The culprit was a nested for loop I copied from a tutorial and never actually read line by line, so the inner loop ran 100 times for all 100 outer items. I had zero clue what the fix was, so I sat there with print statements everywhere like a clown until a friend on Discord said 'dude, just read the indent level.' It took me the rest of the night to figure out that one misplaced line was doing all the damage. Here's my opinion, and I know some of you will hate it: if you can't explain each loop out loud, you should not paste it into your file. Copying without reading is the fastest way to learn nothing and waste a whole evening. Has anyone else had a copy paste mistake blow up like this, and what was the dumbest one?