title: How to insert elements in a nested List in Python?
body: <p>I do not have much experience in Python. 
  All I want to do is to insert elements in nested lists.I have two lists which seems to be similar but their behaviour is completely different.</p>
  
  <p><code>list1 = [['a','b']] * 3
  list2 = [['a','b'],['a','b'],['a','b']]
  </code></p>
  
  <p>When I output print these two lists both give same output: 
  <code>[['a', 'b'], ['a', 'b'], ['a', 'b']]</code></p>
  
  <p>But when I try to insert elements in nested lists both do that in a different way. Below is the code for inserting elements in nested list.</p>
  
  <pre><code>list1 = [['a','b']] * 3
  for item in list1:
    item.append("Hello")
  print (list1)
  </code></pre>
  
  <p>This outputs</p>
  
  <p><code>[['a', 'b', 'Hello', 'Hello', 'Hello'], ['a', 'b', 'Hello', 'Hello', 'Hello'], ['a', 'b', 'Hello', 'Hello', 'Hello']]</code></p>
  
  <p>While when I define list in the following way it does exactly what I want.</p>
  
  <pre><code>list2 = [['a','b'],['a','b'],['a','b']]
  for item in list2:
    item.append("Hello")
  print (list2)
  </code></pre>
  
  <p>This gives following output:
  <code>[['a', 'b', 'Hello'], ['a', 'b', 'Hello'], ['a', 'b', 'Hello']].</code></p>
  
  <p>Why are these two behaving differently?
      <code>list1 = [['a','b']] * 3</code>
      <code>list2 = [['a','b'],['a','b'],['a','b']]</code>
  <a href="https://i.stack.imgur.com/hqP5s.png" rel="nofollow noreferrer">Screenshot of Program output</a></p>