Can someone tell me in the code below, how to prevent "Cvalue" being appended to "fred" when I only want it to be appended to result[key]?
I'm using python 2.7, but python 3 behaves the same.
#!/usr/bin/env python
hdict = {52951331: [5], 23396132: [4], 82982473: [19, 37], 126988879: [20] }
Cdict = {23396132: [19, 37], 82982473: [4], 126988879: [5], 52951331: [20]}
result = {}
for key, value in hdict.iteritems():
if key in Cdict:
result[key] = value
for Cvalue in Cdict[key]:
fred = value
print 'fred1: ', fred
result[key].append(Cvalue)
print 'fred2: ', fred