itertools.combinations_with_replacement()

  • + 0 comments

    from itertools import combinations_with_replacement s,k=input().split() s=sorted(s) l=list(combinations_with_replacement(s,int(k))) x=list() y="" for i in l: for j in i: y+="".join(j) x.append(y) y="" x.sort() for i in x: print(i)