Python list iterator behavior and next(iterator)
What you see is the interpreter echoing back the return value of next() in addition to i being printed each iteration: >>> a = iter(list(range(10))) >>> for i in a: … print(i) … next(a) … 0 1 2 3 4 5 6 7 8 9 So 0 is the output of print(i), 1 the return … Read more