Aug-06-2021, 05:38 PM
Another option is wrapping in a try/except block and raising an exception. You could just raise without the try except if you dont mind seeing the traceback
try: for i in range(5): print(i) if i == 3: raise UserWarning('Exit Early') print('foobar') except: pass