For instance, lets say we call the function countPositive([1,2,3]), it will return a 3. Or if we have the array, [-1,0,1], there is one positive, so the function will return 1. So on, and so forth.
For instance, lets say we call the function countPositive([1,2,3]), it will return a 3.
Share
Some timeit results (on a new macbook air w/1.8 i7, 4 gigs, and cpython 2.7):
filter+len:sum(recommended by hochl):So the
sumversion is slightly faster, but I think thelen+filteris more readable.