We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
from itertools import permutations
def permutation():
user_input = input()
input_list = user_input.split()
var1, var2 = input_list[0], int(input_list[1])
k = list(permutations(var1, var2))
new_list = ["".join(i) for i in k]
for element in sorted(new_list):
print(element)
if name == "main":
permutation()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
itertools.permutations()
You are viewing a single comment's thread. Return to all comments →
from itertools import permutations def permutation(): user_input = input() input_list = user_input.split() var1, var2 = input_list[0], int(input_list[1]) k = list(permutations(var1, var2)) new_list = ["".join(i) for i in k] for element in sorted(new_list): print(element) if name == "main": permutation()