I have 2 lists, one has unique values and the other has repeating values from the first list, I want to modify the second list to contain index positions of the first list as the new values.
list_2
should be [0, 0, 2, 1, 0]
This is the solution I have but I was wondering if it could be done in 1 line, in list_2
without creating a new list.
list_1 = ['a', 'b', 'c']
list_2 = ['a','a','c','b','a']
# new should be [0, 0, 2, 1, 0]
new = []
for i,j in enumerate (list_1):
for i in list_1:
if i in list_2:
new = [list_1.index(p) for p in list_2]