[Solved] String intersection in Python


You can try something like this without importing any module :

s1='appleandgold'
s2='appleblue'

track=[]
for k in range(len(s1)):
    if k!=0:
        for ka in range(0,len(s1),k):
            if s1[ka:ka+k] in s2:
                track.append((len(s1[ka:ka+k]),s1[ka:ka+k]))
print(max(track)[1])

output:

apple

solved String intersection in Python