This answer works very well for finding indices of items from a list in another list, but the problem with it is, it only gives them once. However, I would like my list of indices to have the same length as the searched for list. Here is an example:
thelist = ['A','B','C','D','E'] # the list whose indices I want
Mylist = ['B','C','B','E'] # my list of values that I am searching in the other list
ilist = [i for i, x in enumerate(thelist) if any(thing in x for thing in Mylist)]
With this solution, ilist = [1,2,4]
but what I want is ilist = [1,2,1,4]
so that len(ilist) = len(Mylist)
. It leaves out the index that has already been found, but if my items repeat in the list, it will not give me the duplicates.