itertools.combinations()

  • + 0 comments

    from itertools import combinations

    string,k = input().split()

    [[print(*i,sep="") for i in combinations(sorted(string),i)] for i in range(1,int(k)+1)]