title: How to replace values in Python nested lists without saving only the last value of the iteration
body: <p>I am trying to add/replace an i element on the i-th list of a list, however, only the last iteration is saved. It would be great to understand why this happens and what a workaround this would be. I'm interested in an output that looks like this: <code>[[[0], [], [], []], [[1], [], [], []], [[2], [], [], []], [[3], [], [], []]]</code>, but instead I get this: <code>[[[3], [], [], []], [[3], [], [], []], [[3], [], [], []], [[3], [], [], []]]</code></p>
  
  <pre><code>matrix = [ [ [] * 4] * 4] * 4
  print('pre_matrix=',matrix)
  for m in range(len(a) + 1):
      matrix[m][0] = [m]
      print('m={}, matrix[m]={}'.format(m, matrix[m]))
  print('post_matrix=', matrix)
  
  # This is what the response looks like:
  # pre_matrix= [[[], [], [], []], 
  # [[], [], [], []], 
  # [[], [], [], []], 
  # [[], [], [], []]]
  #
  # m=0, matrix[m]=[[0], [], [], []]
  # m=1, matrix[m]=[[1], [], [], []]
  # m=2, matrix[m]=[[2], [], [], []]
  # m=3, matrix[m]=[[3], [], [], []]
  #
  # post_matrix= [[[3], [], [], []], 
  # [[3], [], [], []], 
  # [[3], [], [], []], 
  # [[3], [], [], []]]
  </code></pre>