Python Dictionary counting the values against each key
<p>I have a list of dictionaries that looks like this:</p>

<pre><code>[{'id':1,'name':'Foo','age':20},{'id':2,'name':'Bar'}]
</code></pre>

<p>How can I get count of total values against each key i.e 3 against id:1</p>

<p>You can use <code>len()</code> on dictionaries to get the number of keys:</p>

<pre><code>&gt;&gt;&gt; a = [{'id':1,'name':'Foo','age':20},{'id':2,'name':'Bar'}]
&gt;&gt;&gt; len(a[0])
3
&gt;&gt;&gt; len(a[1])
2
</code></pre>

python dictionary