Python dictionary: number of keys with specific number of values
<p>I have a huge dictionary that looks like this: </p>

<pre><code>data = {'this': [{'DT': 100}], 'run': [{'NN': 215}, {'VB': 2}], 'the': [{'NNP': 6}, {'JJ': 7}, {'DT': 39517}]}
</code></pre>

<p>What I would like to to do is to run enquires that would return ,for example, the number of keys with exactly two values, in which case the answer is one because <code>'run'</code> is the only one with exactly two values <code>{'NN': 215}</code> &amp; <code>{'VB': 2}</code></p>

<p>I think this could be done with regular expression but could not find out how. </p>

<p>Just get the lengths and count the desired length.</p>

<pre><code>&gt;&gt;&gt; map(len, data.values()).count(2)
1
</code></pre>

python dictionary