I'd like to find if a list of substrings is contained in a list. For example, I have:
string_list = ['item1', 'item2', 'subject3', 'subject4']
and list of substrings
substrings = ['item', 'subject']
I'd like to find if 'item' or 'subject' are included in any item of string_list. Individually, I would do something like:
any('item' in x for x in string_list)
This works for one substring but I would like to find a pretty way of searching for both strings in the list of substrings.
anys, or write a more complex generator expression to create the cross product, or useitertools.productto do it for you.string_liststarts with thesubstringitem, or exact matches?