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
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")
Comments
Leave a comment