insert

iteration_utilities.nth_combination(iterable, r, index)

Equivalent to list(itertools.combinations(iterable, r))[index].

New in version 0.9.0.

Parameters
iterableiterable

The iterable to combine with itertools.combinations().

rint

The number of elements to combine.

indexint

The index of the combination.

Returns
random_combinationtuple

The nth combination.

Examples

>>> from iteration_utilities import nth_combination
>>> nth_combination([1,2,3,4,5,6], r=4, index=2)
(1, 2, 3, 6)