itertools.combinations_with_replacement()

  • + 0 comments
    from itertools import combinations_with_replacement
    
    word , length = input().strip().split()
    
    word =sorted(word)
    length = int(length)
    
    combination = combinations_with_replacement(word,length)
    for combo in combination:
        print(''.join(combo))