2.9.1.1 Try-Except Blocks
Python Programming
In Python, the try block lets you test a block of code for errors, and the except block lets you handle errors if occur.
Example
python
Input a
try :
result =10/a # This line creates error if the value of ‘a’ is 0
except ZeroDivisionError:
print("You can’t divide by zero!")