Python allows you to define exception handlers that catch and handle the runtime errors that your program detects.
Here is an example of an exception handler in Python:
try: cost = totalcost / days print "Cost per day:", cost except ZeroDivisionError: print "Division by zero error detected: number of days is 0"
The following sections provide an overview of what syntax and runtime errors are, and then describe how to add an exception handler to your program.
For a complete list of the error names defined in Python, see the Built-in Exceptions section of the Python documentation.