In this lesson, you’ll learn about the itertools
module. This module helps you create iterators for efficient looping:
>>> import itertools as it
>>> rep = it.repeat(1)
>>> next(rep)
1
>>> next(rep)
1
You’ll also learn about:
itertools.cycle
, which infinitely cycles through iterablesitertools.permutations
, which finds all the permutations (order matters)itertools.combinations
, which finds all the combinations (order does not matter)
You can check out the Python documentation on the itertools
module.
James Uejio RP Team on April 27, 2020
Here is the Python documentation on the
itertools
module: Python itertools module