So I have a list of string which looks something like that -
['https://images.website.com/images/data/X/source1',
'https://images.website.com/articles/data/main_data/source2',
'https://images.website.com/harmony/data/Y/source3',
'https://images.website.com/files/data/Z/source4',
'https://images.website.com/pictures/data/T/source5']
I need to find the item which has main_data in it.
I thought of something like.
def func():
for item in list:
if item.index('/main_data/'): # not -1
return item
return -1 # item not found
Is it the fastest way when I have a list of 100-1000 and maybe more items?