I have 2 lists
lst = [1,2,3,4,5,1,2,1,2,3]
lst2 = [1,2,3]
I am trying to see the index elements in lst
are in lst2
. Currently I am doing;
ind = []
for x in lst2:
if x in lst:
ind.append(lst.index(x))
I realize the problem is that lst.index(x)
only returns the first occurrence of the element so x=1
will always return lst.index(1) = 0
.
Is there a way to return all the indexes that contain the element?