title: A simple coding issue
body: <p>I need your help.
  I am confused about the output of the following code.</p>
  
  <hr>
  
  <pre><code>a = []
  b = []
  
  for j in range(2):
      b.append(j)
  a.append(b)
  print(b)
  print(a)
  
  for i in range(2):
      b.append(i)
  print(b)
  print(a)
  
  a.append(b)
  print(a)
  </code></pre>
  
  <hr>
  
  <p>I thought that the 3rd "print(a)" should give [[0,1],[0, 1, 0, 1], but it actually gives [[0, 1, 0, 1], [0, 1, 0, 1]].
  It seems that after the 2nd loop the "a" is automatically updated, sth that is not happening in the following case, for example, where both prints should give 0:</p>
  
  <hr>
  
  <pre><code>x=0
  y=x
  print(y)  
  x=9
  print(y)
  </code></pre>
  
  <hr>
  
  <p>Does anyone know what changes from the 1st "print(a)" to the 2nd and why they give different outputs?</p>
  
  <p>Thanks!</p>
  
  <p><a href="https://i.stack.imgur.com/XFrko.jpg" rel="nofollow noreferrer">The code along with the outputs</a></p>