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
| Name | Type | Description |
|---|---|---|
| iterable | iterable | Input values, consumed as needed. |
| r | int | Number 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)))