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>Many appropriate answers already given. Of course, an alternative is to filter the list on the type of the element you are querying for first.</p>

<pre><code>&gt;&gt;&gt; a = ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9]
&gt;&gt;&gt; def count(li, item):
...     return list(filter(lambda x: type(x) == type(item), li)).count(item)
...
&gt;&gt;&gt;
&gt;&gt;&gt; count(a, 0)
10
&gt;&gt;&gt; count(a, False)
1
&gt;&gt;&gt; count(a, "a")
1
&gt;&gt;&gt; class my_own_int(int): pass
...
&gt;&gt;&gt; a.append(my_own_int(5))
&gt;&gt;&gt; a.count(5)
1
&gt;&gt;&gt; count(a, 5)
0
</code></pre>

<p>In case you are worried about the copy, you can use <code>sum</code> and abuse the fact we are trying to circumvent above (that <code>True == 1</code>).</p>

<pre><code>def count(li, item):
    return sum(map(lambda x: x == item, filter(lambda x: type(x) == type(item), li))) 
</code></pre>

python list count boolean