I have one reference list, such as :
dico = [ 'test', 'blabla' ]
And I would like to remove these items that are contains in an other list :
listTest = [ 'S01_test', 'S02_ahah', 'S03_blabla' ]
The result should be :
[ 'S02_ahah' ]
I try to use sets, but with no success. Any ideas ?
Thank you 🙂
You can do this with a list comprehension:
Or with
filter():If you are on
python-3.xremember to wrapfilter()withlist()since it returns an iterator:I would have probably prefer the use of
filter()with alambdaover the list comprhension, but from a very basic timing the comprehension seems to be faster.