I am sure there is a better way to describe my problem (hence why I haven't found much on google), but I want to compare two separate strings and pull the substrings they have in common.
Say I have a function that takes two arguments, "hello,world,pie"
and "hello,earth,pie"
I want to return "hello,pie"
How could I do this? Here is what I have so far
def compare(first, second):
save = []
for b, c in set(first.split(',')), set(second.split(',')):
if b == c:
save.append(b)
compare("hello,world,pie", "hello,earth,pie")