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()
.- r
int
The number of elements to combine.
- index
int
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)