itertools.combinations()

  • + 1 comment
    from itertools import combinations
    mystr, k=list(input().split(' '))
    string = sorted(mystr)
    for x in range(1,int(k)+1):
        res = list(combinations(string, x))
        for i in sorted(res):
            restr = ''.join(i)
            print(restr)
        rest = ''
    
    • + 0 comments

      Hi, bro.

      When you use split(), it returns a list, so you don't need to use list().