To filter list of strings by another list of strings in Python we can use the following code:
result = [x for x in strings1 if x in strings2]
But how can we filter list of substrings by another list of strings? For example:
substrings = ['a', 'b', 'c']
strings = ['_b_', '_c_', '_d_']
Result should be:
result = ['b', 'c']
[i for i in substrings for j in strings if i in j]