Find all index position in list based on partial string inside item in list
indices = [i for i, s in enumerate(mylist) if 'aa' in s]
Your idea to use enumerate()
was correct.
indices = []
for i, elem in enumerate(mylist):
if 'aa' in elem:
indices.append(i)
Alternatively, as a list comprehension:
indices = [i for i, elem in enumerate(mylist) if 'aa' in elem]