Intermediate · Lesson 10 of 12
Handling errors
Failures are part of a program, not an unusual exception to learning. Catch a specific failure near the operation that can fail. Give useful feedback and preserve enough context to recover without silently hiding the problem.
Try it for yourself
Run the example, then change one thing and see what happens.
main.pyYour ideas, in code.
Loading your editor…
Run your code to see the output here.
Ready to buildUTF-84 lines
Expected output
Please enter a number.
Make it your own
Change the invalid input into a valid number and compare the result.
A quick check
Which habit helps when learning handling errors?