◐ Shell
clean mode source ↗

Python Language Tutorial => Filter Function

Example

Filter takes a function and a collection. It returns a collection of every item for which the function returned True.

arr=[1,2,3,4,5,6]
[i for i in filter(lambda x:x>4,arr)]    # outputs[5,6]

Got any Python Language Question?

pdf PDF - Download Python Language for free



Previous Next