Skipping Iterations in Python
You are looking for continue.
for i in iterator:
try:
# Do something.
pass
except:
# Continue to next iteration.
continue
Example for Continue:
number = 0
for number in range(10):
number = number + 1
if number == 5:
continue # continue here
print('Number is ' + str(number))
print('Out of loop')
Output:
Number is 1
Number is 2
Number is 3
Number is 4
Number is 6 # Note: 5 is skipped!!
Number is 7
Number is 8
Number is 9
Number is 10
Out of loop