I'm trying to get a piece of code to return the index of where the match was found within the list, so that another item can be compared to this index. (essentially allowing two separate strings to be compared to the same item on a list). I'm able to get the match if it matches exactly, but can't get it to work with a partial string. Here is some pseudo code to show what I have:
mylist = ['abc', 'def', 'ghi', 'jkl', 'mno']
str1 = 'does mn have anything to do with it?'
str2 = 'I think mn is there'
b = [i for i, s in enumerate(mylist) if str1 in s]
print(b)
So my question is how can I get the index of 'mno' to return so that I can compare str2 against it after the first check. If there's a better way around this problem id love to hear it