May 2017
Intermediate to advanced
280 pages
6h 2m
English
In this section, you will see how to use the try...except block to handle the exceptions. Let's understand the usage of the try...except block with examples.
Consider the following program:
def sum1(a,b): c = a+b return cprint sum1(10,0)
Consider that a third person edits the program calc.py; the full program is shown here:
def sum1(a,b): c = a+b return cdef divide(a,b): c = a/b return c print divide(10,0)print sum1(10,0)
Let's run the program:

In the preceding output, the program is showing an error because we performed division by 0. Due to one error, the whole program stop. In ...
Read now
Unlock full access