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>Another option is to first "decorate" the list by adding the types and the count:</p>

<pre><code>decorated_seq = list(map(lambda x: (x, type(x)), sequence))
decorated_seq.count((0, type(0)))
</code></pre>

<p>If you want to have <code>0 == 0.0</code> you could do:</p>

<pre><code>decorated_seq = list(map(lambda x: (x, isinstance(x, bool)), sequence))
decorated_seq.count((0, False))
</code></pre>

<p>Which counts all <code>0</code>s that are <em>not</em> of type <code>bool</code> (i.e. <code>False</code>s).
In this way you can define what <code>count</code> should do in any way you want, at the cost of creating a temporary list.</p>

python list count boolean