calling exception in python code example
Example 1: try except python
def sum_of(x, y):
try:
print(x + y)
except TypeError:
print("Invalid argument specified.")
Example 2: python: raise error
class MyError(TypeError):
pass
raise MyError('An error happened')