Prefix Suffix
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
first = str(input())
second = str(input())
i = 0
suffix = ""
while i < len(first):
suffix += first[i]
if second.endswith(suffix):
break
if suffix not in second:
suffix = ""
break
i += 1
print(suffix)
Comments
Leave a comment