I've run into a strange inconsistency. This is a simplified version of the problem:
func1={
'flist':[12,13,14],
'fnum':10
}
dlist=func1['flist']
dnum=func1['fnum']
dlist+=[16]
dnum+=1
print(func1)
print(dnum)
The output is:
{'flist': [12, 13, 14, 16], 'fnum': 10}
11
Why is that the changes to the variable dlist
are carried over to flist
in func1
, but changes in dnum
are not carried over to fnum
in func1
?
flist
has changed, fnum
has not.