This should work:
def endOverlap(a, b):
for i in range(0, len(a)):
if b.startswith(a[-i:]):
return i
return 0
a = "Hey there"
b = "there is a ball"
c = "here is a ball"
d = "not here is a ball"
print(a, b, endOverlap(a, b))
print(a, c, endOverlap(a, c))
print(a, d, endOverlap(a, d))
Edit: modified to return length of overlap and to be more efficient if only small parts of the string are expected to overlap. Then fixed a bug.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…