>>> # Measure some strings:
... words = ['cat', 'window', 'defenestrate']
>>> for w in words:
... print(w, len(w))
...
cat 3
window 6
defenestrate 12
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)