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