I want to restart the current iteration of the first for loop when testing12(bad_order, order) == True. I have tried to use continue but it skips over the iteration which is not what I want.
bad_order = []
order = []
for iteration in range(0, 10):
args = []
print("\n def test%d(self):" % (iteration))
for input in range(num_arguments):
args.append(pick_type())
order = args
if testing12(bad_order, order) == True:
continue
try:
result = target(*args)
code = test_to_string(target, args, result)
except Exception as error:
bad_order = args
code = test_to_string_exc(target, args, error)
You can add an inner while loop which will in effect repeat the outer loop iteration until it exits. If you can put the repeat condition in the while test, then you're done:
for iteration in range(0, 10):
while some_condition:
...
If not, you can use a while True loop, put an unconditional break at the bottom, and use a continue to repeat:
for iteration in range(0, 10):
while True:
...
if continue_condition:
continue
...
break
you can also change the:
for iteration in range(0,10):
to
iteration =0
while iteration < 10 :
and increment iteration only when no repeat is needed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With