Write a program to check the overlapping of one string's suffix with the prefix of another string.
def overlap(s_2, s_1):
if len(s_1) > len(s_2):
l = len(s_2)
else:
l = len(s_1)
for i in range(l, 0, -1):
if s_1[:i] == s_2[len(s_2)-i:]:
return f'suffix of {s_2} and prefix of {s_1} is {s_1[:i]}'
return 'no overlaps'
s_1 = input('first string: ')
s_2 = input('second string: ')
print(overlap(s_1, s_2))
Comments
Leave a comment