itertools.permutations()

  • + 0 comments

    from itertools import permutations from re import sub

    s, k = input().split() k = int(k)

    res = sorted(permutations(s, k))

    for p in res: word = "".join(p) print(sub(r'[^a-zA-Z0-9]', ' ', word))