I have a set of indices in a list:
[2 0 3 4 5]
And I want to replace them by values stored in another list:
[a b c d e f g]
And output:
[c a d e f]
I tried this code:
for line in indices:
print(line)
for value in line:
value = classes[value]
print(line)
break
which prints the original list twice. Is there a way to replace the elements or am I forced to create a new list of lists?
print. What do you mean by "replacing the elements"? you don't want to do that! leave the input lists alone, and simply create a new one with the answer, as shown in my solution.