permutation and combination

 

permutations('ABCD', 2)

AB AC AD BA BC BD CA CB CD DA DB DC

combinations('ABCD', 2)

AB AC AD BC BD CD




Python is such a powerful programming language: https://docs.python.org/3.8/library/itertools.html