Answers for "python get index of substring in liast"

2

python get index of substring in liast

index = [idx for idx, s in enumerate(l) if 'tiger' in s][0]
Posted by: Guest on October-07-2020
0

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
Posted by: Guest on October-07-2020

Code answers related to "python get index of substring in liast"

Python Answers by Framework

Browse Popular Code Answers by Language