filter
filter(function, iterable)
filter
will return an iterable object that will return all the items of the original iterable that evaluate the function to True.
This can have only one iterable!
numbers = [1, 3, 27, 10, 38]
def big(n):
return n > 10
big_numbers = filter(big, numbers)
print(big_numbers)
#print(list(big_numbers))
for num in big_numbers:
print(num)
Output:
<filter object at 0x7f4bc37355c0>
[27, 38]