I am trying to write a program which will search through a series of strings and return true if any part of a substring is found.
For example, say the substring I am interested in is:
GATCGATC
The program should return True for:
GGTGGATCGATC
And should also return true for (because it ends with GATC):
GGTGTTTTGATC
So far I have:
def matchpat(str1, str2):
'''Find a pattern in a string'''
if str1 in str2:
return True
else:
return False
This function works, but only if the whole pattern is present, it will return False for partial matches.
TrueandFalsecases.This is not workingshould also returnTRUEbecause it ends with a substring ofGATCGATC? (The sentence contains the letterG, which is a substring ofGATCGATC)