I want to get all the unique permutations for a 4 character string using 2 A and 2 B
from itertools import permutations
perm = permutations('AABB', 4)
for i in list(perm):
print(i)
This gets me
('A', 'A', 'B', 'B')
('A', 'A', 'B', 'B')
('A', 'B', 'A', 'B')
('A', 'B', 'B', 'A')
...
As you can see I get duplicates. I guess this is because it treats the A in the 1st place and 2nd place are different values, but to me AABB is simply 1 unique result.
I can workaround this results by throwing all of them into a set to get rid of the dups, but I think I'm just using the permutation function wrong.
How do I use permutation function to get all the unique permutations with using 2 A's and 2 B's without getting the dups?