itertools - Unordered Pairs (pair sets) in Python from a list -
i have list of items
alist = ['dog', 'cat', 'fish'] i want return unique unordered pairs, in case:
(dog,cat)(dog,fish)(fish,cat) itertools.combinations not take account unordered condition, not quite need.
where problem itertools?
import itertools alist = ['dog', 'cat', 'fish'] result in itertools.combinations(alist, 2): print result output:
('dog', 'cat') ('dog', 'fish') ('cat', 'fish')
Comments
Post a Comment