python get index from string in lsit code example
Example 1: python get index of substring in liast
def index_containing_substring(the_list, substring):
for i, s in enumerate(the_list):
if substring in s:
return i
return -1
Example 2: python get index of substring in liast
index = [idx for idx, s in enumerate(l) if 'tiger' in s][0]