python PROGRAM TO INPUT 2 STRINGS AND CHECK IF ONE OF THE STRING IS A PREFIX OF THE OTHER.
Answers
Answered by
0
import re
test_str1 = "Gfgisbest"
test_str2 = "bestforall"
print("The original string 1 is : " + str(test_str1))
print("The original string 2 is : " + str(test_str2))
res = ''
for char in range(len(test_str1)):
if test_str2.startswith(test_str1[char:]):
res = test_str1[char:]
break
print("Overlapped String : " + str(res))
Similar questions