← Go Back

How to Merge Two Iterators

Using the itertools standard module:

>>> import itertools
>>> it1 = range(5)
>>> it2 = range(5, 11)
>>> it3 = itertools.chain(it1, it2)
>>> list(it3)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


iterators


🐍 You might also find interesting: