23
Built my first calculator app and it broke on purpose
I spent 4 hours making a simple calculator in Python that kept returning wrong answers for division by zero. Turns out Python has a built in error for that and I learned about try/except blocks by accident. Did anyone else figure out error handling because your code straight up crashed first?
2 comments
Log in to join the discussion
Log In2 Comments
tarajenkins17d ago
Broken code is the whole point though. That's literally how everyone learns. Python even gives you a clear error message about division by zero. Why would you want a calculator that just silently returns wrong answers? Try/except blocks are good for hiding bugs if you don't know what you're doing. Real programmers just handle edge cases before they cause crashes. Your calculator working by accident doesn't mean you learned error handling right. You just slapped a bandaid on a problem you didn't understand in the first place.
4
hugo23817d ago
It reminds me of people who ignore their check engine light and just hope the car keeps running. Sure, you can cover up the problem with try/except blocks, but eventually that hidden issue is going to come back and bite you when you least expect it. Better to know exactly what's broken and fix it right.
4