Moving back an iteration in a for loop
for loops in Python always go forward. If you want to be able to move backwards, you must use a different mechanism, such as while: i = 0 while i < 5: print(i) if condition: i=i-1 i += 1 Or even better: i = 0 while i < 5: print(i) if condition: do_something() # don’t … Read more