Answer to Question #242176 in Python for Rishi

Question #242176
Write a program to check the overlapping of one strings suffix with the prefix of another string
1
Expert's answer
2021-09-26T02:42:21-0400
fst = str(input("First string: "))
sec = str(input("Second string: "))
ans= ""
len1, len2 = len(fst), len(sec)
for i in range(len1):
    overlap = ""
    for j in range(len2):
        if (i + j < len1 and fst[i + j] == sec[j]):
            overlap += sec[j]
        else:
            if (len(overlap) > len(ans)):
                ans = overlap
                overlap = ""


print(ans)

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