Answer to Question #328338 in Python for Pavan kalyan

Question #328338

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

1
Expert's answer
2022-04-13T13:24:28-0400
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")

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