T
T
TreShk02018-03-05 11:34:42
Python
TreShk0, 2018-03-05 11:34:42

Is it possible to use multiple conditions in filter lambda?

Is it possible to somehow use several conditions in filter lambda and how? for examplelist(filter(lambda x: x != 5 or x != 2, nums))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-03-05
@TreShk0

Can. Lambda is a regular function with no side effects. In this case, you just need to use the correct logical operator:
list(filter(lambda x: x != 5 and x != 2, nums))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question