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

Popular posts from this blog

c - sscanf() double showing zeros -

pentaho - Carte Status / Kettle Slave Server Status page shows status for random runs instead of the latest run -