Home / Python Exceptions / How to Handle an Exception in Python In this example we will show how to handle an exception using the try statement in Python. Source Code try: x = int('a') except: print('An exception occurred!') Output: An exception occurred!