Iteration Classes

itertools.combinations_with_replacement()

Choose r input positions in nondecreasing order, allowing repeated use of a position.

Formal Syntax & Structure

python syntaxpython
itertools.combinations_with_replacement(iterable, r)

Parameters & Attributes

NameTypeDescription
iterableiterableInput values, consumed as needed.
rintNumber of positions in each result; nonnegative.

Return Value

iterator

The iterator result described above.

Working Example

Example Snippetpython
import itertoolsprint(list(itertools.combinations_with_replacement("AB",2)))
Python Reference