 <p>You are very confused about python data structures, you can't have keys in lists, you don't need a list of dictionaries with only one key. So assuming what you really want is a dictionary where keys are the portfolio, and value is a dictionary of the sum of <code>buy</code> and <code>sell</code> as separate values:</p> <pre><code>&gt;&gt;&gt; results = {} &gt;&gt;&gt; for t in my_list: ... trans = 'BUY' if t['trans'] &gt; 0 else 'SELL' ... a = results.setdefault(t['portfolio'], {'BUY':0, 'SELL':0}) ... a[trans] += t['trans'] &gt;&gt;&gt; results {'ABC': {'BUY': 0, 'SELL': 0}, 'XYZ': {'BUY': 0, 'SELL': 0}} </code></pre>