Answers for "get index of a string series python"

4

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
-1

python string index of

sentence = 'Python programming is fun.'

result = sentence.index('is fun')
print("Substring 'is fun':", result)

result = sentence.index('Java')
print("Substring 'Java':", result)
Posted by: Guest on May-30-2020

Code answers related to "get index of a string series python"

Python Answers by Framework

Browse Popular Code Answers by Language