title: About slicing of lists in Python
body: <p>I am trying to make two copies of a list, using slicing, called <code>testlist</code>. The two copies are <code>test1</code>,<code>test2</code>. Now I am editing <code>test2</code> and the values of <code>test1</code> change. I am not sure why this is happening? I know that slicing creates a new copy of <code>testlist</code>(with a different reference) but somehow <code>test1</code> and <code>test2</code> are still related. Any ideas why? Here is the code:</p>
  <pre><code>testlist=[[[1,1,1],[1,1,1],[1,1,1]]]
  vertices=[]
  m=3
  for i in range(m):
      for j in range(m):
          vertices.append([i,j])
  randv=random.choice(vertices)[:]
  test1=testlist[-1][:]
  print('test1: ')
  print(test1)
  test2=testlist[-1][:]
  M=[[4,4,4],[4,4,4],[4,4,4]]
  uniformv=random.uniform(0,1)
  prob=np.exp(beta*M[randv[0]][randv[1]])/(np.exp(beta*M[randv[0]][randv[1]])+np.exp(-beta*M[randv[0]][randv[1]]))
  if uniformv&lt;prob:
      test2[randv[0]][randv[1]]=+1
  else:
      test2[randv[0]][randv[1]]=-1
  print('test1: ')
  print(test1)
  </code></pre>
  <p>The print statement for <code>test1</code> before and after editing <code>test2</code> yields:</p>
  <pre><code>test1: 
  [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
  test1: 
  [[1, 1, 1], [1, 1, -1], [1, 1, 1]]
  </code></pre>
  <p>Please run the code a few times to see different values for <code>test1</code> because of the usage of random variables.</p>