>>> n = [1,2,3,4]
>>> filter(lambda x:x>3,n)
>>> len(filter(lambda x:x>3,n))
Traceback
Generally, filter and reduce are not pythonic.
@arshajii metioned this solution:
len([x for x in n if x > 3])
This is quite simple, but is not describing what you exactly want to do, and it makes a list that may use some additional memory.
A better solution is using sum with generator:
sum(1 for x in n if x > 3)
(See more about generator here: https://www.python.org/dev/peps/pep-0289/#rationale)
However, sum with generator is actually slower in most cases because of the implementation (tested in CPython 3.6.4):
In [1]: %timeit len([1 for x in range(10000000)])
356 ms ± 17.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [2]: %timeit sum(1 for x in range(10000000))
676 ms ± 7.05 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)