0
Tried to fix my first Python script and broke everything worse
Spent 3 hours last night trying to add a simple if/else statement to a calculator program I was making. Got it running but then it kept printing "Invalid input" no matter what number I typed. Turned out I put the else block inside the wrong indentation level. My buddy Mike laughed and said "welcome to Python". Anyone else spend way too long on one dumb syntax mistake?
2 comments
Log in to join the discussion
Log In2 Comments
seanjohnson1mo ago
Blame the indentation thing all you want but honestly 3 hours on an if/else block sounds like you need to slow down and read your own code line by line. Ive had nights where I moved a bracket one space and the whole thing exploded too but eventually you just learn to double check before running it 50 times. Not saying its not frustrating, but calling it a huge deal feels like overreacting a bit. Just fix the indent and move on, man.
6
janab821mo ago
Oh man, I have to agree with @seanjohnson on this one. A buddy of mine once spent almost four hours trying to figure out why his loop wasn't working, and it turned out he had a semicolon after the if statement. He was about to throw his laptop out the window until I made him read it aloud to me. Once he slowed down and actually said each line out loud, he spotted it in like two minutes. It's so easy to get tunnel vision and just keep hitting run without really looking at what you wrote. Maybe it feels like a big deal in the moment, but stepping back for a second usually saves way more time. Do you ever try reading your code out loud to catch stuff like that?
2