Answers for "check string in a list for substrings and return index"

0

check string in a list for substrings and return index

def get_index(list_of_strings, substring):
    try:
        return next(i for i, e in enumerate(list_of_strings) if substring in e)
    except StopIteration:
        return len(list_of_strings) - 1
Posted by: Guest on September-16-2021

Code answers related to "check string in a list for substrings and return index"

Python Answers by Framework

Browse Popular Code Answers by Language