title: how does a function changes the value of a variable outside its scope? Python
body: <p>i was coding this code and noticed something weird, after my function has been called on the variable, the value of the variable gets changed although <strong>its outside of the functions scope</strong>, how exactly is this happening?</p>
  <pre><code>def test(my_list):
    if 11 in my_list and sum(my_list) &gt; 21:
      my_list.remove(11)
      my_list.append(1)
    return sum(my_list)
  
  
  ca = [11,11]
  print(test(ca))
  print(ca)
  </code></pre>
  <p>the above code results to:</p>
  <pre><code>12
  [11, 1]
  </code></pre>