I'm trying to get from:
list = ['a', 'b', 'c', 'd']
to:
combinations = [['a','b'], ['a','c'], ['a','d'],
['b','c'], ['b','d'],
['c','d']]
(formatting just for readability in stackoverflow)
So, the cartesian product, all combinations, distinct regardless of order, and no ['a','a']
responses.
I've tried using zip ( tuple(zip(list*4))
) and itertools (both permutations and product list(itertools.product(list, list))
) but am struggling to clean it up. Itertools kind of works but I'm struggling to remove the dupes.
Is there a cleaner way? If not, please can someone help me out with the itertools response