Python‎ > ‎itertools‎ > ‎

itertools.combinations()

http://www.adilwaseem.com/

Definition 
Return successive r-length combinations of elements in the iterable.

Syntax
combinations(iterable, r) --> combinations object

Parameters
iterable
r=number

Examples
The return is equivalent to following:
 import itertools
set={"Python", "Lake", "learning", "Center"}
y=itertools.combinations(set,3)
for value in y: print(value)

>>> 
('Center', 'learning', 'Lake')
('Center', 'learning', 'Python')
('Center', 'Lake', 'Python')
('learning', 'Lake', 'Python')
>>>

Comments