Python - Filter list comprehension



    Daniel Carretero


    The code creates a new list by iterating through the initial list and checking each item against a predicate. If the predicate evaluates to true, the item is added to the new list.

    newlist = [x for x in initial_list if not predicate(x)]
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.