Python: Intersection of full string from list with partial string
Question: Let's say I have a string and a list of strings:

    
    
    a = 'ABCDEFG'
    
    b = ['ABC', 'QRS', 'AHQ']
    

How can I pull out the string in list b that matches up perfectly with a
section of the string a? So the would return would be something like `['ABC']`

The most important issue is that I have tens of millions of strings, so that
time efficiency is essential.


Answer: If you only want the first match in b:

    
    
    next((s for s in b if s in a), None)
    

This has the advantage of short-circuiting as soon as it finds a match whereas
the other list solutions will keep going. If no match is found, it will return
`None`.

