title: Appending a list by assigning values from another list by changing some elements python
body: <p>I have a list, and I want to construct another list from this list, by discarding some elements, and changing some elements. I am doing the following:</p>
  
  <pre><code>gridAtoms = someFunction() # a list of lists. gridAtoms[i][6] is [float,float,float]
  occ = someOtherFunction() # a 3D numpy array
  
  occGridAtoms = []
  selectedOcc = []
  for i, atom in enumerate(gridAtoms):
      coord = np.array(atom[6])
      x = int(round(b1.dot(coord) / spacing[0]))
      y = int(round(b2.dot(coord) / spacing[1]))
      z = int(round(b3.dot(coord) / spacing[2]))
      selectedOcc.append(occ[x, y, z])
      currentAtom = list(atom)
      currentAtom[7][0] = occ[x, y, z]
      if occ[x, y, z] &gt;= 0.01:
          occGridAtoms.append(list(currentAtom))
  </code></pre>
  
  <p>The problem is, even though I do <code>currentAtom = list(atom)</code> instead of just <code>currentAtom = atom</code>, the elements of <code>gridAtom</code>, specifically, <code>gridAtom[i][7][0]</code> change. Why does this happen even though I create a new list by using <code>list()</code>? And how can I keep <code>gridAtoms</code> unchanged?</p>