How do I create a cartesian product of a list itself with unique elements?
For example, lists = ['a', 'b', 'c']
, and I want to create [['a', 'b'], ['a','c'], ['b','c']]
.
How do I create a cartesian product of a list itself with unique elements?
For example, lists = ['a', 'b', 'c']
, and I want to create [['a', 'b'], ['a','c'], ['b','c']]
.
from itertools import combinations
lists = ['a', 'b', 'c']
print(list(map(list, combinations(lists,2))))