I have two sequences AAAAAAAAAGAAAAGAAGAAG, AAAGAAG. The correct answer is AAGAAG.
But my code gives AA.
There will also be times when two strings will be in this order AAAGAAG, AAAAAAAAAGAAAAGAAGAAG.
Here is my code
`def longestSubstringFinder(string1, string2):
string1=string1.strip()
string2=string2.strip()
answer = ""
len1=len(string1)
len2=len(string2)
if int(len1)>1 and int(len2)>1:
for i in range(1,len1,1):
match = ""
for j in range(len2):
if len1>len2:
if i+j<len1 and (string1[i+j]==string2[i+j]):
match=str(match)+str(string2[i+j])
print(match)
else:
if len(match)>len(answer):
answer=match
match=""
elif len2>len1:
if i+j<len2 and (string1[i+j]==string2[i+j]):
match=str(match)+str(string2[i+j])
print(match)
else:
if len(match)>len(answer):
answer=match
match=""
return(answer)`