title: Why is my function modifying the input variable?
body: <p>Hi I have a function that rotates a matrix, however I can't figure out why it works.</p>
  
  <pre><code>def rotate(matrix):
          matrix[:] = [[row[i] for row in matrix[::-1]] for i in range(len(matrix))]
  </code></pre>
  
  <p>I understand "[:]" creates a copy of the original matrix, but why is the original matrix getting rotated as well?</p>
  
  <p>If I want to return a new rotated matrix without modifying the input, what can I do?</p>
  
  <p>Thank you!!!</p>