title: python: mutating the copy of a list changes the original?
body: <p>So until now, i was under the assumption that if you have for example:</p>
  
  <pre><code>L = [1,2,3]
  L2 = L1
  L2.append(5)
  </code></pre>
  
  <p>both L and L2 would be affected by the append code. </p>
  
  <p>however, when you assign L2 to be a copy of a list, for example:</p>
  
  <pre><code>L = [1,2,3]
  L2 = L[:]
  L2.append(5)
  </code></pre>
  
  <p>only L2 would be affected, and L still refers to [1,2,3]</p>
  
  <p>but i now run into this:</p>
  
  <pre><code>x = [1, 2]
  L1 = [x, [8, 9]]
  L2 = L1[:]
  L2[0][1] = 999
  
  &gt;&gt;&gt;print(L1)
  [[1,999],[8,9]]
  &gt;&gt;&gt;print(L2)
  [[1,999],[8,9]]
  </code></pre>
  
  <p>why was it that in this case, both lists changed?</p>