title: Why does modifying copy of array affect original?
body: <p>Hi everyone I am sorry if this is a noob question but I am using python and I have an issue where I copy an array but then when I modify the copy it affects the original. I want to add a linear offset from the boundaries matrix to a set of coordinates:</p>
  
  <pre><code>boundaries = [[5.818, 0.0, 0.0], [0.0, 5.818, 0.0], [0.0, 0.0, 5.818]]
  
  xyzCoord = [[0.0, 0.0, 0.0], [2.909, 2.909, 0.0], ...
  
  extraX=[]
  for i in range(0,len(xyzCoord)):
      toAdd=[]
      toAdd=xyzCoord[i]
      toAdd[0]=toAdd[0]+boundaries[0][0]
  
  print xyzCoord
  </code></pre>
  
  <p>The output I expect is that xyzCoord should not be affected because I make a duplicate (toAdd) and then modify that. Strangely enough this loop does affect my xyzCoord:</p>
  
  <p>The output is:</p>
  
  <pre><code>[[5.818, 0.0, 0.0], [0.0, 5.818, 0.0], [0.0, 0.0, 5.818]]
  
  [[0.0, 0.0, 0.0], [2.909, 2.909, 0.0], ...
  
  [[5.818, 0.0, 0.0], [8.727, 2.909, 0.0], ...
  </code></pre>
  
  <hr>
  
  <p>EDIT: For context, the idea is that I want to eventually make a separate list with the transposed values and then ultimately create an intercalated list but this part is holding me up. I.e. I would ideally like to create:
     [[0.0, 0.0, 0.0], [5.818, 0.0, 0.0], [2.909, 0.0, 0.0], [8.727, 2.909, 0.0]...]
  and then make a larger loop for Y and Z. This way I could propagate some coordinates in the X Y and Z and arbitrary number of times.</p>