11
Question about my first Python script and a weird bug
I tried to make a simple script to count how many times the word 'hello' shows up in a text file. I ran it on a file with 10 lines, but it kept saying 'hello' was there 0 times. I spent an hour checking my code before I saw I typed 'helo' with one L in the script. It was looking for a word that wasn't there. Has anyone else had a tiny typo break their whole program?
3 comments
Log in to join the discussion
Log In3 Comments
diana6412mo ago
Typos are the worst kind of bug because they look so right. Your brain just fills in the missing letter without you noticing. It happens to everyone who writes code, honestly.
8
luna_craig582mo agoMost Upvoted
Last month I spent three hours looking for a bug that was just a missing comma in a list. My brain kept reading it as correct every single time. Now I paste my code into a text to speech reader and listen to it. Hearing the words out loud catches those sneaky typos my eyes skip over. It feels silly but it actually works.
5
dakota_taylor391mo ago
Read an article once about how our brains are basically wired to auto-correct what we see, especially with familiar words. That's why proofreading your own code is so hard. They suggested changing the font or printing it out to trick your brain into seeing it fresh. Makes sense, right?
1