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>If you run into that kind of problems frequently you can introduce the following class<sup>*</sup></p>

<pre><code>class Exactly:
    def __init__(self, something):
        self.value = something

    def __eq__(self, other):
        return type(self.value) == type(other) and self.value == other
</code></pre>

<p>and use it as follows:</p>

<pre><code>a.count(Exactly(0)) 
</code></pre>

<hr>

<p><sup>*</sup> Of course you may need to enhance it for other operations too.</p>

python list count boolean