I want to find and replace multiple values in an 1D array / list with new ones.
In example for a list
a=[2, 3, 2, 5, 4, 4, 1, 2]
I woul
Try this for your expected output, works even if elements not in value_old.
elements
value_old
>>>[val_new[val_old.index(i)] if i in val_old else i for i in a] [3, 4, 3, 1, 5, 5, 2, 3]