from itertools import permutations perm = permutations([1,2,3]) for i in perm: print(i)