In this example we will show how to execute the specified code block whether the try block raises an error in Python.
Source Code
try:
x = int('a')
except:
print('An exception occurred!')
finally:
print('The exception is clear.')
Output:
An exception occurred!
The exception is clear.