Documentation

filter

While simple filters can be performed with list subtraction, more complex filters can be implemented with the filter function. filter takes two arguments, the first being a list and the second being a function that returns a bool and take the keyword argument key. It returns a list containing all elements for which the function passed returned True.

def key_fn(key=0):
  return key > 5
return filter([1, 4, 7, 10], key_fn) # [7, 10]