title: Why isn't append() appending the swapped list. It is appending original string but printing swapped list
body: <p>nums: List whose permutations I need to find.
  Leetcode problem: 46. 
  I need to return a matrix containing all permutations of a list. When it reaches end of backtracking, I print nums and even append nums to matrix. It is printing swapped nums but it is appending original nums. Can some explain me the reason or how do I sought this problem out?</p>
  
  <p>I tried creating v as a global matrix but it doesn't work.</p>
  
  <pre class="lang-py prettyprint-override"><code>class Solution:
      def permutation(self, v, nums, l, r):
          if l == r-1:
              print(nums)
              v.append(nums)
          else:
              for i in range(l, r):
                  nums[i], nums[l] = nums[l], nums[i]
                  self.permutation(v, nums, l+1, r)
                  nums[i], nums[l] = nums[l], nums[i]
              return v
  
      def permute(self, nums: List[int]) -&gt; List[List[int]]:
          v = []
          return self.permutation(v, nums, 0, len(nums))
  '''
  
  Input:[1,2,3]
  Printing:
  [1, 2, 3]
  [1, 3, 2]
  [2, 1, 3]
  [2, 3, 1]
  [3, 2, 1]
  [3, 1, 2]
  Output:
  [[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]]
  
  Expected:
  [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
  </code></pre>