appending nested list - is it supposed to work this way?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/240178/unexpected-feature-in-a-python-list-of-lists">Unexpected feature in a Python list of lists</a><br>
  <a href="http://stackoverflow.com/questions/2397141/how-to-initialize-a-two-dimensional-array-in-python">How to initialize a two-dimensional array in Python?</a>  </p>
</blockquote>



<p>I wanted to create a nested list of nsize and then append items into it one by one according to a criterion.</p>

<p>For this I wrote it like following ( nsize = 4 )</p>

<pre><code>a = [[]] * 4  # which creates on display a = [ [] , [] , [] , [] ]
</code></pre>

<p>Now I do something like this <code>a[1].append(3)</code> which gives me the output <code>[[3], [3], [3], [3]]</code></p>

<p>What am I doing wrong here ? Should'nt only the 2nd list ( a[1] ) be updated with the value 3 ?</p>
