Find common substring between two strings
I'd like to compare 2 strings and keep the matched, splitting off where
the comparison fails.
So if I have 2 strings -
string1 = apples
string2 = appleses
answer = apples
Another example, as the string could have more than one word.
string1 = apple pie available
string2 = apple pies
answer = apple pie
I'm sure there is a simple Python way of doing this but I can't work it
out, any help and explanation appreciated.
No comments:
Post a Comment