itertools.combinations()

  • + 0 comments
    from itertools import combinations
    S, k = input().split()
    S = sorted(S)
    k = int(k)
    for x in range(1, k + 1):
        for y in combinations(S, x):
            print(''.join(y))