Q:

Cross-matching two lists

I have two lists where I am trying to see if there is any matches between substrings in elements in both lists.
["Po2311tato","Pin2231eap","Orange2231edg","add22131dfes"]
["2311","233412","2231"]

If any substrings in an element matches the second list such as "Po2311tato" will match with "2311".  Then I would want to put "Po2311tato" in a new list in which all elements of the first that match would be placed in the new list. So the new list would be                                        ["Po2311tato","Pin2231eap","Orange2231edg"]  

A:

You can use the syntax 'substring' in string to do this:
a = ["Po2311tato","Pin2231eap","Orange2231edg","add22131dfes"]
b = ["2311","233412","2231"]

def has_substring(word):
    for substring in b:
        if substring in word:
            return True
    return False

print filter(has_substring, a)

Hope this helps!

