代碼1:code
>>> l1=range(3) >>> l2=l1 >>> l2+=[4] >>> l1 [0, 1, 2, 4] >>> l2 [0, 1, 2, 4]
代碼2:get
>>> l2=l1 >>> l2=l2+[4] >>> l1 [0, 1, 2] >>> l2 [0, 1, 2, 4]
Why does += behave unexpectedly on lists?io