itertools.combinations()

  • + 0 comments

    from itertools import combinations S,k=input().split() S="".join(sorted(S)) k=int(k) for i in range(1,k+1): li=list(combinations(S,i)) li=["".join(i) for i in li] print(*li,sep="\n")