Spent 2 hours hunting a bug in my first Python script, turns out I wrote 'totl' instead of 'total'
Last Tuesday I was working through a beginner Python tutorial in my kitchen and wrote a little script to add up my grocery spending for the week. It ran fine at first, then crashed with a NameError that made zero sense to me. I stared at that screen for about 2 hours, reading the same 15 lines over and over, googling the error, and even retyping the whole file from scratch. I almost posted it to a Discord server to ask for help, but right before I did I noticed I had typed 'totl' instead of 'total' on one line. One missing 'a' broke the whole thing. I felt dumb for about 5 seconds and then honestly kind of relieved, because it meant my logic was fine and it was just a typo. Now I read my own code out loud like a weirdo before I assume the computer is wrong. Does anyone have a trick for catching typos like that faster, or is staring at it for 2 hours just part of the deal?
My buddy Dave once spent a whole Sunday on a bash script that kept failing, and the problem was he named his variable "coun" instead of "count" three separate times. He started printing every variable right after he made it, just a quick print line, and that caught the dumb stuff in seconds. So yeah, two hours of staring is pretty much the deal at first, but little checks like that can save you a lot of it.