import time for i in range(0,3): print(i) time.sleep(1) raise Exception("Reached end")