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