How to remove an array containing certain strings from another array in Python -
example:
a = ['abc123','abc','543234','blah','tete','head','loo2']
so want filter out above array of strings following array b = ['ab','2']
i want remove strings containing 'ab' list along other strings in array following:
a = ['blah', 'tete', 'head']
you can use list comprehension:
[i in if not any(x in x in b)]
this returns:
['blah', 'tete', 'head']
Comments
Post a Comment