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.
def merge_the_tools(string, k):
mylist = []
word = ""
for x in string:
word +=x
if len(word)==k:
mylist.append(word)
word = ""
if word :
mylist.append(word)
ret_list = []
for x in mylist:
temp_word = ""
for y in x :
if y not in temp_word:
temp_word+=y
ret_list.append(temp_word)
for x in ret_list:
print(x)
if name == 'main':
string, k = input(), int(input())
merge_the_tools(string, k)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Merge the Tools!
You are viewing a single comment's thread. Return to all comments →
def merge_the_tools(string, k): mylist = [] word = "" for x in string: word +=x if len(word)==k: mylist.append(word) word = "" if word : mylist.append(word) ret_list = [] for x in mylist: temp_word = "" for y in x : if y not in temp_word: temp_word+=y ret_list.append(temp_word) for x in ret_list: print(x) if name == 'main': string, k = input(), int(input()) merge_the_tools(string, k)