Python Program to Check Overlapping Prefix – Suffix in Two Lists
Given 2 Strings, our task is to check overlapping of one string’s suffix with prefix of other string.
Input : test_str1 = "Gfgisbest", test_str2 = "bestforall" Output : best Explanation : best overlaps as suffix of first string and prefix of next. Input : test_str1 = "Gfgisbest", test_str2 = "restforall" Output : '' Explanation : No overlapping.
In this, we increment the first list and slice till list end and keep comparing with the prefix substring of other string using startswith(). In this, the word that occurs at end of string is compared with once with prefix of 2nd string.
The original string 1 is : Gfgisbest The original string 2 is : bestforall Overlapped String : best