title: Python: about [:] and its behavior in a function
body: <pre><code>def call(nums):
      nums[:] = [x for x in nums if x != 4]
  
  numbers = [4, 5]
  print(numbers)
  call(numbers)
  print(numbers)
  </code></pre>
  
  <p>The output for the above code is:</p>
  
  <pre><code>[4, 5]
  [5]
  </code></pre>
  
  <p>But if you remove the "[:]", the output becomes the following:</p>
  
  <pre><code>[4, 5]
  [4, 5]
  </code></pre>
  
  <p>I know that <code>[:]</code> makes a copy of the full list, but why the function argument is modified in one case and not in the other?</p>