itertools.permutations()

  • + 0 comments

    Easy 3 liner. Could be two lines but that's ugly code lol

    from itertools import permutations
    S, k = input().split()
    [print(''.join(x)) for x in sorted(permutations(S, int(k)))]