itertools.combinations()

  • + 0 comments

    Enter your code here. Read input from STDIN. Print output to STDOUT

    from itertools import combinations if name == "main": s , k = input().split() final_list=[] for i in range(1,int(k)+1): final=[] result = list(combinations(s,i)) for x in result: x = list(x) x.sort() final.append("".join(x)) final.sort() final_list.extend(final)
    print("\n".join(final_list))