0
The challenge: to receive a string s and an integer k, then you must separate the string into sub-strings of length s/k and finally remove the repeated letters in each sub-string. Follows the code:
def merge_the_tools(string,k):
n=len(string)
merge= n//k
separador=[]
lista=[]
for i in range(merge):
start= int(i*n/merge)
end= int((i+1)*n/merge)
separador.append(string[start:end])
for i in range(len(separador)):
lista.append(list(separador[i]))
return lista
aux=[]
result=merge_the_tools('AABCAAADA', 3)
for i in range(len(result)):
aux.append(list(set(result[i])))
print(aux[i])
But when printing the output I have to have the following answer:
AB
CA
AD
And what I have is a reverse response when I use the set():
BA
AC
DA
I can’t understand why.