PythonBuilt-infilter
map

filterBuilt-in

sorted

Filters elements of an iterable using a function.

Syntax

filter(function, iterable)

Example

Enter values below to update the example in real time.

nums
evens
list
filter
lambda
print
nums = [1, 2, 3, 4, 5, 6]
evens = list(filter(lambda x: x % 2 == 0, nums))
print(evens)  # [2, 4, 6]