📜  检查子字符串列表中的字符串并返回索引 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:21.331000             🧑  作者: Mango

代码示例1
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