Write a programe to check the overlapping of one string's suffix with the prefix of another string
string1 = input("Enter the first string:\n")
string2 = input("Enter the second string:\n")
index = 0
len1 = len(string1)
len2 = len(string2)
start = 0
if len1 > len2:
start = len1 - len2
else:
start = 0
match = False
while start < len1:
i = start
while string1[i] == string2[i - start]:
if i == len1 - 1:
match = True
break
i += 1
if match:
break
start += 1
if match:
print("String are overlapped with common substring '{}'".format(string1[start:]))
else:
print("Strings are not overlapped")
Comments
Leave a comment