Summation of elements of dictionary that are list of lists
<pre><code>d = {
  'a': [[1, 2, 3], [1, 2, 3]],
  'b': [[2, 4, 1], [1, 6, 1]],
}

def add_element(lst):
    ad = [sum(i) for i in zip(*lst)]
    return ad

def csv_reducer2(dicty):
    return {k: list(map(add_element, v)) for k, v in dicty.items()}

csv_reducer2(d)
</code></pre>

<p>required output:</p>

<pre><code>{'b': [3, 10, 2], 'a': [2, 4, 6]}
</code></pre>

<p>Above is the code I have been trying but it gives an error</p>

<blockquote>
  <p>zip argument #1 must support iteration</p>
</blockquote>

<p>The following will work on Python 2 or 3:</p>

<pre><code>&gt;&gt;&gt; {k: [a + b for a, b in zip(*v)] for k, v in d.items()}
{'a': [2, 4, 6], 'b': [3, 10, 2]}
</code></pre>

<p>The issue with your code is you are mapping <code>add_element</code> to every individual element in <code>v</code> inside your dictionary comprehension. This passes a one-dimensional list to <code>zip</code> in <code>add_element</code>, resulting in your error (since individual integers don't support iteration.</p>

python list dictionary