itertools.combinations()

  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    from itertools import combinations
    
    S = input().split()
    for i in range(1,int(S[1])+1):
        for l in combinations(sorted(S[0].upper()), i):
            print(''.join(l))