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

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -