Reputation: 1221
suppose I have two string list:
a=['ab','ac','ad']
b=['abcd','baa','bacd','bbaa']
and I want to know if each element of list b has any of strings in a as its substring. The correct result should be: [True,False,True,False]. How do I code this?
Upvotes: 1
Views: 65
Reputation: 6658
Something like:
[any([i in j for i in a]) for j in b]
would do the trick.
Upvotes: 0