, ( " python, in, get specific elements" ) . filter , , len , . , , - , , list.count, - .
len(filter(lambda x: 'hello' == x, cells))
len([x for x in cells if x == 'hello'])
(, , !):
cells.count(' ')
:
% python -m timeit -s "data = ['hello' for x in range(100000)]" "[x for x in data if x == 'hello']"
100 loops, best of 3: 6.97 msec per loop
% python -m timeit -s "data = ['hello' for x in range(100000)]" "filter(lambda x: x == 'hello', data)"
100 loops, best of 3: 13.3 msec per loop