Answer to Question #337741 in Python for Mamatha

Question #337741

Input: ramisgood


goodforall.



Output: good.




1
Expert's answer
2022-05-06T14:52:01-0400
string1 = input()
string2 = input()
result = ""
len1, len2 = len(string1), len(string2)
for i in range(len(string1)):
    for j in range(len(string2)):
        local_ind = 0
        max_match = ''
        while ((i + local_ind < len(string1)) and (j + local_ind < len(string2)) and string1[i + local_ind] == string2[
            j + local_ind]):
            max_match += string2[j + local_ind]
            local_ind += 1
        if len(max_match) > len(result):
            result = max_match
print(result)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS