itertools.combinations()

  • + 0 comments

    from itertools import combinations

    a, b = input().split()

    a =sorted(str(a))

    A = []

    x = int(b) for i in range(1, int(b)+1): A.append(list(combinations(a, i))) x += i

    for j in range(int(b)): for i in range(len(A[j])): print(''.join(A[j][i]))