culTest

    One of the 50 questions in this topic

    How much do you know about Python?

    What does the filter() function do in Python?

    Answers

    Filter errors in the code
    Create a new iterable with elements that meet a conditionCorrect
    Remove duplicate values ​​from a list
    Apply a visual filter to images

    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].