Unsupported operand type for - list and list
<p>I am using an older version of python which doesnt have support to subtract dict's.</p>

<pre><code>d1={'ab': ['3'], 'hij': ['1200']}
d2={'ab': ['1'], 'hij': ['600']}
</code></pre>

<p>Basically my code looks like this:</p>

<pre><code>  for key in d1.keys():
        if key in d2:
            d3[key]=d1[key]-d2[key]
</code></pre>

<p>output should be like</p>

<pre><code>d2={'ab': ['2'], 'hij': ['600']}
</code></pre>

<p>It returns unsupported operand type for - : list and list.
Any ideas on how to get around this</p>

<p>Try the following:</p>

<pre><code>d1={'ab': ['3'], 'hij': ['1200']}
d2={'ab': ['1'], 'hij': ['600']} 
d3={}
for key in d1.keys():
    if key in d2:
        d3[key] = [str(int(d1[key][i]) - int(d2[key][i])) for i in xrange(len(d1[key]))]
print d3
</code></pre>

python python-2.7