from itertools import permutations string="SOFT" a=permutations(string) for i in list(a): # join all the letters of the list to make a string print("".join(i))