Answer to Question #255681 in Python for chethan

Question #255681

write a program to check the overlapping of one string's suffix with the prefix of another string


1.Sample input:

ramisgood

goodforall

Sample Output:

good

2.Sample input:

finally

restforall

sample input:

No overlapping




1
Expert's answer
2021-10-26T11:45:45-0400
w_1 = input()
w_2 = input()
if len(w_1) > len(w_2):
    i = len(w_2)
else:
    i = len(w_1)
overlap = ""
while i > 0:
    if w_1[len(w_1)-i:] == w_2[:i]:
       overlap = w_2[:i]
       break
    i -= 1
if len(overlap) > 0:
    print(overlap)
else:
    print("No overlapping")

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