T
14

Why did my code work before and break after one line?

I'm on my 6th week of learning Python, just working through small practice projects. Last Tuesday I made a simple calculator and it ran fine, then I added one line to round the output and suddenly it threw an error about a NoneType object. I spent an hour staring at it before realizing I forgot to assign the return value from my function. Has anyone else hit a tiny change that completely flipped your script from working to broken in a second?
1 comments

Log in to join the discussion

Log In
1 Comment
terrymitchell
Oh, I know that pain all too well. Last month I spent two evenings hunting down a bug in a little weather app I was making, and it turned out I had typed `print` instead of `return` in one spot. The program looked fine, but it was quietly giving me nothing. I've learned the hard way that Python does not care how confident you feel, it will gladly hand you a NoneType and walk away. These tiny little changes are like stepping on a crack in the sidewalk, one minute you're fine, the next you're flat on your face in front of your own code.
4