title: Different way to create list within a list
body: <p>I have a question about how to create a list within a list. For example, we use</p>
  <pre><code>[[0] * n for _ in range(m)] 
  </code></pre>
  <p>to create a matrix with dimension <code>n*m</code>. However, when I tried the similar thing to create a nested list.</p>
  <pre><code>l = [[(0, 1)]] * n 
  </code></pre>
  <p>And then update the <code>l[0]</code>, I find the <code>l[1]</code> would also get updated. However, the approach <code> l = [[(0, 1)] for _ in range(n)]</code> produces what I need.</p>
  <p>Would you please help me understand this issue?</p>
  <p>Thanks for your help.</p>
  <blockquote>
  <p>Follow up:
  In the dynamic programming, we use [-math.inf]*n to construct a list and then update the values. Why this approach works, but the above approach failed? Thanks.</p>
  </blockquote>