Answer to Question #206209 in Python for siva

Question #206209

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



1
Expert's answer
2021-06-16T05:23:12-0400
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))

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