I have a list
a = ['A', 'B', 'C']
and from that list, How to get all the 2 by 2 combinations? Like this:
A, B
A, C
B, A
B, C
C, A
C, B
I have a list
a = ['A', 'B', 'C']
and from that list, How to get all the 2 by 2 combinations? Like this:
A, B
A, C
B, A
B, C
C, A
C, B
>>> from itertools import permutations
>>> a = ['A', 'B', 'C']
>>> list(permutations(a,2)) # see second argument which specifies permutation length
[('A', 'B'), ('A', 'C'), ('B', 'A'), ('B', 'C'), ('C', 'A'), ('C', 'B')]