title: When I create a list of list in Python, why do all my inner lists get the same values?
body: <p>So, I was working on Python for making List of arrays for my project work. </p>
  
  <p>Sample code:</p>
  
  <pre><code>var0 = 0
  var1 = 0
  car = [0,0]
  listitem = [car[:] for i in range(10)]
  for i in range(10):
      car[0] = var0 + i + 1
      car[1] = var1 + i
      listitem[i] = car
  print listitem
  </code></pre>
  
  <p>As the logic would suggest we would be expecting an output like:</p>
  
  <pre><code>[[1,0],[2,1],[3,2],[4,3],[5,4],[6,5],[7,6],[8,7],[9,8],[10,9]]
  </code></pre>
  
  <p>But the output comes as:</p>
  
  <pre><code>[[10,9],[10,9],[10,9],[10,9],[10,9],[10,9],[10,9],[10,9],[10,9],[10,9]]
  </code></pre>
  
  <p>I have come with a theory where the car array uses some pointers to the variable space.</p>
  
  <p>Does anyone has a probable explanation for the same?
  Thank you</p>