a = 0 for i in range(0, 1000000): try: a += 1 raise Exception("boom") except Exception: a -= 1 print a