A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-140.py
1it=iter(range(10))
2importitertools
3head=list(itertools.islice(it,3))
4print(head)
5print(next(it))
Iteration
Answer & explanation
Console output
[0, 1, 2]
3
Why
itertools.islice consumes items from the underlying iterator as it yields them. Slicing the first 3 advances it to have already produced 0, 1, 2, so the subsequent next(it) returns 3. The iterator is shared and stateful.