How to get the item currently pointed at by iterator without incrementing?
Iterators don't have a way to get the current value. If you want that, keep a reference to it yourself, or wrap your iterator to hold onto it for you.
looking_for = iter(when_to_change_the_mode)
current = next(looking_for)
for l in listA:
do_something(current)
if l == current:
current = next(looking_for)
Question:
What if at the end of the iterator? The next
function allows for a default parameter.