from itertools import permutations s = list(permutations('1234')) a = [list(i) for i in s] s2 = ["".join(i) for i in a] print(s2) print(len(s2))