I have a list like below, I want to find simple permutation with little bit modification,
For Example
l=['a', 'b']
Output:
[('a', 'a'), ('a', 'b'), ('b', 'b')]
I followed,
Try-1
list(itertools.product(L, repeat=2))
returns,
[('a', 'a'), ('a', 'b'), ('b', 'a'), ('b', 'b')]
Try -2
print list(itertools.permutations(['a', 'b']))
returns,
[('a', 'b'), ('b', 'a')]
Try-3
i can do like below,
temp= [tuple(sorted((i,j))) for i in ['a', 'b'] for j in ['a', 'b']]
print list(set(temp))
But it seems inefficient way to solve this.