title: Python Two-Dimensional Query..
body: <p>I am seeing a very unusual behavior in python.. Kindly let me know what am i doing wrong!!</p>
  
  <pre><code>bc = [[0]*(n+1)]*(n+1)
  
  for i in range(n+1):
      bc[i][i] = 1
  
  print (bc)        
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]
  </code></pre>
  
  <p>I am trying to initialize the diagonal elements of two dimensional array to 1, but it is initializing all the elements with 1. I think I am doing something wrong with accessing two dimensional Array..</p>
  
  <p>Also, kindly let me know how can I use two loops to access all the elements of two dimensional array.. my next step.. </p>
  
  <p>Thanks.</p>