title: What are the differences between .reverse() and [::-1]? Python list .reverse() works but [::-1] does not
body: <p>This is a problem from leetcode. I think lots of you are probably familiar with.</p>
  <pre class="lang-py prettyprint-override"><code>class Solution:
      def rotate(self, matrix: List[List[int]]) -&gt; None:
      &quot;&quot;&quot;
      Do not return anything, modify matrix in-place instead.
      &quot;&quot;&quot;
      matrix.reverse()
      n=len(matrix)
      for i in range(n):
          for j in range(i):
              matrix[i][j],matrix[j][i]=matrix[j][i],matrix[i][j]
  </code></pre>
  <p>With the code above, if input is [[1,2,3],[4,5,6],[7,8,9]].
  Then, the output is [[7,4,1],[8,5,2],[9,6,3]] which is expected.</p>
  <p>But, if I use matrix{::-1]:</p>
  <pre class="lang-py prettyprint-override"><code>class Solution:
      def rotate(self, matrix: List[List[int]]) -&gt; None:
      &quot;&quot;&quot;
      Do not return anything, modify matrix in-place instead.
      &quot;&quot;&quot;
      matrix=matrix[::-1]
      n=len(matrix)
      for i in range(n):
          for j in range(i):
              matrix[i][j],matrix[j][i]=matrix[j][i],matrix[i][j]
  </code></pre>
  <p>If I just change .reverse() to [::-1], the output is [[9,6,3],[8,5,2],[7,4,1]].</p>
  <p>I don't understand why am I getting these different results. Other than .reverse() being inplace, [::-1] create a new list, is there any other different between them? Thank you for your help!</p>