itertools.permutations()

  • + 0 comments

    Here is the solution:

    from itertools import permutations s,k = input().split() res = sorted(permutations(s,int(k))) for i in res: print("".join(i))