itertools.permutations()

  • + 0 comments
    from itertools import permutations
    s, n = input().split(" ")
    [ print(''.join(x)) for  x in sorted(permutations(s,int(n)))]