I'm trying to find a way to use one list to filter out elements of another.
Kinda like the intersect syntax but the exact opposite
lst = [0,1,2,6]
secondlst = [0,1,2,3,4,5,6]
expected outcome
[3,4,5]
Simple way:
r = [v for v in secondlst if v not in lst]
or
list(set(secondlst).difference(lst))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With