title: appending to a nested list in python
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument">“Least Astonishment” in Python: The Mutable Default Argument</a><br>
    <a href="https://stackoverflow.com/questions/1605024/python-using-the-multiply-operator-to-create-copies-of-objects-in-lists">Python - Using the Multiply Operator to Create Copies of Objects in Lists</a>  </p>
  </blockquote>
  
  
  
  <p>Python behaves unexpected when i append to a list, which is in another list. Here's an example:</p>
  
  <pre><code>&gt;&gt;&gt; _list = [[]] * 7
  &gt;&gt;&gt; _list
  [[], [], [], [], [], [], []]
  &gt;&gt;&gt; _list[0].append("value")
  </code></pre>
  
  <p>What i expect:</p>
  
  <pre><code>&gt;&gt;&gt; _list
  [['value'], [], [], [], [], [], []]
  </code></pre>
  
  <p>What i get:</p>
  
  <pre><code>&gt;&gt;&gt; _list
  [['value'], ['value'], ['value'], ['value'], ['value'], ['value'], ['value']]
  </code></pre>
  
  <p>Why is this? how can i go around it?</p>