Ask Your Question

Revision history [back]

The following

R = iter(range(9))
for r in R:
    if r == 3:
        a = next(R)   # remove the next element from the iterator
    print(r)

produces

0
1
2
3
5
6
7
8