title: Copying nested lists in Python
body: <p>I want to copy a 2D list, so that if I modify one list, the other is not modified.</p>
  
  <p>For a one-dimensional list, I just do this:</p>
  
  <pre><code>a = [1, 2]
  b = a[:]
  </code></pre>
  
  <p>And now if I modify <code>b</code>, <code>a</code> is not modified.</p>
  
  <p>But this doesn't work for a two-dimensional list:</p>
  
  <pre><code>a = [[1, 2],[3, 4]]
  b = a[:]
  </code></pre>
  
  <p>If I modify <code>b</code>, <code>a</code> gets modified as well.</p>
  
  <p>How do I fix this?</p>