title: Modifying dictionary inside a function
body: <p>I have the following code:  </p>
  
  <pre><code>def modify_dict(my_dict):
      my_dict = {'b': 2}
      print(my_dict)
  
  
  def main():
      my_dict = {'a': 1}
      modify_dict(my_dict)
      print(my_dict)
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>and it's output is:  </p>
  
  <pre><code>{'b': 2}
  {'a': 1}
  </code></pre>
  
  <p>My question is why are the changes done to the dictionary inside the function aren't being reflected in the <code>main()</code> function?<br>
  Also, how can I update the dictionary inside the function so that the changes are reflected outside of the function?</p>