I have a for loop that I'm needing to break if there is an error.
I want to be able to continue a for loop if a boolean is true. But don't want to have to write an "if" statement over and over again. Is it possible to call "continue" outside of a "loop"?
The following code results in an error. But is my thinking of this would work.
_Range = 6
_RangeEnd = 0
def function_to_call():
print("x")
if _Continue is True:
continue
for x in range(_Range):
_RangeEnd = _RangeEnd + 1
function_to_call()
if _RangeEnd == 5:
_Continue = True
If this isn't possible. What would be an efficient way to do this? I'm reusing this function in a good number of different for loops.