When should I use list.count(0), and how do I to discount the "False" item?
<p><code>a.count(0)</code> always returns 11, so what should I do to discount the <code>False</code> and return 10?</p>

<pre><code>a = ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9]
</code></pre>

<p>How about this functional style solution:</p>

<pre><code>print zip(a, map(type, a)).count((0, int))
&gt;&gt;&gt; 10
</code></pre>

<p>Timing this against some of the other answers here, this also seems to be one of the quickest:</p>

<pre class="lang-python prettyprint-override"><code>t0 = time.time()
for i in range(100000):
    zip(a, map(type, a)).count((0, int))
print time.time() - t0
&gt;&gt;&gt; 0.275855064392

t0 = time.time()
for i in range(100000):
    sum(1 for item in a if item == 0 and type(item) == int)
print time.time() - t0
&gt;&gt;&gt; 0.478030204773

t0 = time.time()
for i in range(100000):
    sum(1 for item in a if item == 0 and type(item) is type(0))
print time.time() - t0
&gt;&gt;&gt; 0.52236700058

t0 = time.time()
for i in range(100000):
    sum((x==0 and x is not False) for x in a)
print time.time() - t0
&gt;&gt;&gt; 0.450266122818
</code></pre>

python list count boolean