title: Why defining global <variable name> inside called function works for immutable objects in python3?
body: <pre><code>def func():
      global count
      count += 1
  
  
  if __name__ == '__main__':
      count = 0
      print(count)
      func()
      print(count)
  </code></pre>
  <p>As defined in the python documentation:</p>
  <ol>
  <li><p>If we have a mutable object (list, dict, set, etc.), we can use some specific operations to mutate it and all the variables that refer to it will see the change.</p>
  </li>
  <li><p>If we have an immutable object (str, int, tuple, etc.), all the variables that refer to it will always see the same value, but operations that transform that value into a new value always return a new object.</p>
  </li>
  </ol>
  <p>Its clearly mentioned in the 2nd statement that int is immutable, but if you run the python code above with global it seems to be working.</p>
  <p>Any explanation that anyone can provide here, or i am missing something here?</p>