Is it possible to prevent the for loop from proceeding to the next value in the list/iterator if a certain condition is satisfied?
lst = list('abcde')
for alphabet in lst:
if some_condition:
# somehow prevent the for loop from advancing so that in the
# next iteration, the value of alphabet remains the same as it is now
# do something
I don’t think you can (or should) do this with a regular for list-iterator. You may want to look at this as a case of a work queue and use a while loop: