I want to remove all occurences of two values in a list using one line. I have tried the filter
+ lambda
method and list comprehension, but it's not working the way I would expect.
Something like:
s2 = [0, 0, 3, 11, 14, 17, 18, 18]
# I want to remove all 0 and 18 from s2 list
# i.e. I want output: s2_filter = [3, 11, 14, 17]
s2_filter = filter (lambda a: a != 0 or 18, s2)
>>> s2 = [0, 0, 3, 11, 14, 17, 18, 18] # not what I'm expecting
s2_filter = [i for i in s2 if i != 0 or 18]
>>> s2 = [0, 0, 3, 11, 14, 17, 18, 18] # not what I'm expecting
I guess there is something wrong with the or
but I cannot figure out how I should write this correctly.
Can you help?