"filter" in python

Home Forums Python Programming "filter" in python

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1959 Reply
    Humble
    Keymaster

    This (filter) is similar to map() implementation.. how-ever when “filter()” is used, only the “TRUE” results on sequence items when it gone through function will be returned.. That said, the result is filtered based on “True” value of function return on sequence items.

    Again syntax is similar to map() as discussed in previous post..
    For ex:

    >>>> l=[11,10,23,100]
    >>> list(filter(lambda x: x%10 == 0, l))
    [10, 100]
    >>> list(filter(lambda x: x%10, l))
    [11, 23]
    >>> 
    
Viewing 1 post (of 1 total)
Reply To: "filter" in python
Your information: