Open this example in the interactive library
Source code
from itertools import permutations
print(list(permutations('AB', 2)))Sample output
[('A', 'B'), ('B', 'A')]
Generate permutations. A self-contained example using the Python standard library.
Open this example in the interactive library
from itertools import permutations
print(list(permutations('AB', 2)))[('A', 'B'), ('B', 'A')]