Iteration Classes

itertools.product()

Produce Cartesian products, with the rightmost pool advancing fastest. Inputs are stored in finite pools before results are yielded.

Formal Syntax & Structure

python syntaxpython
itertools.product(*iterables, repeat=1)

Parameters & Attributes

NameTypeDescription
iterablesiterableZero or more input iterables.
repeatintNumber of repetitions of the input pools.

Return Value

iterator

The iterator result described above.

Working Example

Example Snippetpython
import itertoolsprint(list(itertools.product([1,2],"AB")))
Python Reference