On this page
  1. itertools.combinations_with_replacement
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

itertools.combinations_with_replacement

Prev: itertools.combinations | Up: itertools | Next: itertools.compress
Rel: itertools.accumulate, itertools.batched, itertools.chain, itertools.combinations
Ref: docs.python.org — itertools.combinations_with_replacement
Tags: #public #python3 #stdlib #itertools


Import

import itertools
from itertools import combinations_with_replacement

Signature & Overview

itertools.combinations_with_replacement(iterable, r)

Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.

Usage

from itertools import combinations_with_replacement

assert list(combinations_with_replacement("AB", 2)) == [("A", "A"), ("A", "B"), ("B", "B")]

Gotchas

REPL Inspect

from itertools import combinations_with_replacement
help(combinations_with_replacement)

Linked from

Related notes