Multiply keys*values in a dict?
<pre><code>a = {2: 4, 3: 2, 5: 1, 7: 1}
</code></pre>

<p>The keys represent prime numbers; the values represent counters. I want to calculate the number you get by iterating through the dictionary keys*values and summing the total. What is the most Pythonic way to do this? </p>

<pre><code>&gt;&gt;&gt; [k*v for k,v in a.items()]
[8, 6, 5, 7]
</code></pre>

<p>but</p>

<pre><code>&gt;&gt;&gt; sum(k*v for k,v in a.items())
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: 'int' object is not callable
</code></pre>
