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>Solving this problem more generally, you could make your own subclass of list:</p>

<pre><code>class key_equality_list(list):
    def __init__(self, key, items):
        super(key_equality_list, self).__init__(items)
        self._f = key

    def __contains__(self, x):
        return any(self._f(x) == self._f(item) for item in self)

    def count(self, x):
        return sum(self._f(x) == self._f(item) for item in self)
</code></pre>

<p>And then define a key function that checks types:</p>

<pre><code>type_and_val = lambda x: (x, type(x))
</code></pre>

<p>So your usage becomes:</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; a = key_equality_list(type_and_val, a)
&gt;&gt;&gt; a.count(0)
10
&gt;&gt;&gt; a.count(False)
1
</code></pre>

python list count boolean