Answer to Question #258826 in Python for Raju

Question #258826

Prefix Suffix


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


Sample input 1

ramisgood

goodforall

Sample output 1

good


Sample input 2

finally

restforall


Sample output 2

No overlapping


1
Expert's answer
2021-10-30T00:38:57-0400
f_str = input()
s_str = input()
s = "No overlapping"
if len(f_str) > len(s_str):
    i = len(s_str)
else:
    i = len(f_str)
while i > 0:
    if f_str[len(f_str)-i:] == s_str[:i]:
        s = s_str[:i]
        break
    i -= 1
print(s)

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