“Python Get Index of Substring in liast” Code-Antworten

Python Get Index of Substring in liast

index = [idx for idx, s in enumerate(l) if 'tiger' in s][0]
Calm Crossbill

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
Calm Crossbill

Ähnliche Antworten wie “Python Get Index of Substring in liast”

Fragen ähnlich wie “Python Get Index of Substring in liast”

Weitere verwandte Antworten zu “Python Get Index of Substring in liast” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen