itertools.combinations()

  • + 0 comments
    from itertools import combinations
    
    if __name__ == '__main__':
        s, length = input().split()
        
        for i in range(1, int(length)+1):
            print('\n'.join([''.join(t) for t in combinations(sorted(s), i)]))