title: Why is the value of the entire column changing after each iteration instead of just a particular cell?
body: <p>I am trying to convert a python list into a 2d matrix without numpy library. </p>
  
  <p>However, in doing so, my code is not working as expected. </p>
  
  <pre><code>n=3
  arr = [16,13,4,16,13,19,23,8,11]  
  mat=[[0]*n]*n                    #initialising a 3*3 matrix 
  for a in range(n):
      for b in range(n):
          mat[a][b]=arr[b]
          print(mat)               #To understand the result of each iteration
      if len(arr) &gt;n:
          arr=arr[n:] 
  print(mat)
  </code></pre>
  
  <p>The obtained output is:</p>
  
  <blockquote>
    <p>[[16, 0, 0], [16, 0, 0], [16, 0, 0]]<br>
    [[16, 13, 0], [16, 13, 0], [16, 13, 0]]<br>
    [[16, 13, 4], [16, 13, 4], [16, 13, 4]]<br>
    [[16, 13, 4], [16, 13, 4], [16, 13, 4]]<br>
    [[16, 13, 4], [16, 13, 4], [16, 13, 4]]<br>
    [[16, 13, 19], [16, 13, 19], [16, 13, 19]]<br>
    [[23, 13, 19], [23, 13, 19], [23, 13, 19]]<br>
    [[23, 8, 19], [23, 8, 19], [23, 8, 19]]<br>
    [[23, 8, 11], [23, 8, 11], [23, 8, 11]]     </p>
  </blockquote>
  
  <p>finally:                          </p>
  
  <blockquote>
    <p>[[23, 8, 11], [23, 8, 11], [23, 8, 11]]</p>
  </blockquote>
  
  <p>instead of:</p>
  
  <blockquote>
    <p>[[16,13,4], [16,13,19], [23, 8, 11]]</p>
  </blockquote>
  
  <p>Why is the value of the entire column changing after each iteration instead of just that cell?</p>
  
  <p>What possible change in the code can give the desired result(i.e- converting the list of 9 elements to a 3x3 matrix)?</p>