I have two strings:
str1 = "123147"
str2 = "1474671231"
the end of str1 has some similar part with the start of str2 ("147"), and I want to find the length of this similar part, so I tried to:
for ch in str1:
if ch == str2[0]:
start_idx = len(str1) - date.index(ch)
break
However the problem is it will return a mistake if the begin of str1 is same as the begin of str2 ("1") and if I reverse the checking order, it still have this problem ("7"). Is there any simple method to solve it?
Most important, I only want to check the end of str1 and the beginning of str2, and ignore other parts, for example, "1231" in str1 and str2 should be ignored.