title: append in a loop, python
body: <p>I have a really weird problem with append in a list.</p>
  
  <pre><code>import random
  
  def CreatePopulation(a, r):
      pippo=range(a)
      print pippo
      i=0
      prova=[]
      while i&lt;r:
          random.shuffle(pippo)
          print pippo
          prova.append(pippo)
          print prova
          i=i+1
      return prova
  
  pop=CreatePopulation(5,10)
  print pop
  
  example=["a","b"]
  example.append("c")
  print example
  </code></pre>
  
  <p>I can't upload the entire output because the website says that it's bad formatted.
  But the output it's a list with ten times the same value, the last shuffle of x, like this:</p>
  
  <pre><code>[[1, 0, 4, 2, 3], [1, 0, 4, 2, 3], [1, 0, 4, 2, 3], [1, 0, 4, 2, 3], [1, 0, 4, 2, 3],
   [1, 0, 4, 2, 3], [1, 0, 4, 2, 3], [1, 0, 4, 2, 3], [1, 0, 4, 2, 3], [1, 0, 4, 2, 3],
   [1, 0, 4, 2, 3]]
  </code></pre>
  
  <p>But the example append out of the loop works properly:</p>
  
  <pre><code>['a', 'b', 'c']
  </code></pre>
  
  <p>I really can't see why the output it's like this, instead of append at the end, it just create a list with all the same value.
  But if i use append out of the loop it works.</p>