I'm having a very easy problem and I really don't understand why this is happening.
Im learning Python through the website codewars. One of the questions is to separate a sentence and order it by a number that contain each word. For example, if the sentence is "Matias3 I1 a2m" the program should return "I1 a2m Matias3" because of the order of the numbers that contain each word.
This is the code I'm using. It is very simple, but when I assign the new order y[p] = ... the program multiplicates the registers. If I remove that line, the registers are ok and I don't know why.
sentence="is2 Thi1s T4est 3a" #Example of sentence
x=sentence.split(" ") #I create an array with all the words
y= x #I create a second array (y). This is the one I will order by the numbers of the words
for i in range(len(x)): #I make a loop for the array x
print("i: "+str(i))
for j in range(len(x[i])): #I make a look for each character of the word
print(" i:"+str(i)+" j:"+str(j)+" "+x[i])
if x[i][j:j+1].isnumeric(): #If the character is a number, then Id like to put that word in the
#that number position in the y array (of course is the position-1)
p=int(x[i][j:j+1])-1 # This is the position that the word should be
y[p]=x[i] # When I assing y[] to the correct position (I want that the position i
# becomes the position p, the program get lost)
print(y)