title: Python: List in List which keeps the difference between column position and row position
body: <p>Dear all I am new to programming and I am using Python.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>P=[]
  i=0
  j=0
  
  P=[[0]*5]*5
  while i&lt;5:
      for j in range(0,5):
          P[i][j]=i-j
      i=i+1
  print(P)
  </code></pre>
  
  <p>And I expect the following output:</p>
  
  <p>[[0, -1, -2,-3, -4], [1, 0, -1, -2, -3], [2, 1, 0, -1, -2], [3, 2, 1, 0, -1], [4, 3, 2, 1, 0]]</p>
  
  <p>As I would like to keep in the cells the difference between their row number and column.</p>
  
  <p>The program gives the following output:</p>
  
  <p>[[4, 3, 2, 1, 0], [4, 3, 2, 1, 0], [4, 3, 2, 1, 0], [4, 3, 2, 1, 0], [4, 3, 2, 1, 0]]</p>
  
  <p>Thanks in Advance for the help!</p>