Finding the Indices of multiple items in a list, using a list Finding the Indices of multiple items in a list, using a list python python

Finding the Indices of multiple items in a list, using a list


N = []for i in range(len(L)):    if L[i] in R:        N.append(i)

or with a generator

N = [i for i in range(len(L)) if L[i] in R]

or with arrays

import numpy as npN=np.where(np.isin(L,R))


N = []  for i, num in enumerate(L):      if num in R:          N.append(i)