One of the 50 questions in this topic
How much do you know about Python?filter() creates a new iterable with the elements of an original iterable that satisfy a condition defined by a function. For example: list(filter(lambda x: x > 0, [-1, 0, 1, 2])) returns [1, 2]. The function must return a boolean value. As with map(), list comprehensions offer a more readable alternative: [x for x in [-1, 0, 1, 2] if x > 0].