This next()
function retrieves the next item from the iterator by calling its next() method.
next(iterator[, default])
Here,
>>> i = iter([1, 2])
>>> next(i)
1
>>> next(i)
2
>>> next(i)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
StopIteration
>>> i = iter([1, 2])
>>> next(i, 'No more items')
1
>>> next(i, 'No more items')
2
>>> next(i, 'No more items')
'No more items'