Answer to Question #206813 in Python for siva

Question #206813

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


The first line of the input will contain a string A.

The second line of the input will contain a string B.Output


The output should contain overlapping word if present else print "No overlapping".Explanation


For example, if the given two strings, A and B, are "ramisgood" "goodforall"

The output should be "good" as good overlaps as a suffix of the first string and prefix of next.


input:

ramisgood

godforall


output:

good


input-2:

finally

restforall


output:

No overlapping


1
Expert's answer
2021-06-14T15:29:16-0400
def suffix(word1,word2):
    x=2
    overcross=[]
    for i in word1:
        if word1[:x]==word2[-x:]:
            overcross.append(word1[:x])
        x+=1
    x=2
    for i in word1:
        if word1[-x:]==word2[:x]:
            overcross.append(word1[-x:])
        x+=1
    if len(overcross)==0:
        return print('No overlapping')
    else:
        return overcross

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