title: Setting variables with exec inside a function
body: <p>I just started self teaching Python, and I need a little help with this script:</p>
  
  <pre><code>old_string = "didnt work"   
  new_string = "worked"
  
  def function():
      exec("old_string = new_string")     
      print(old_string) 
  
  function()
  </code></pre>
  
  <p>I want to get it so <code>old_string = "worked"</code>.</p>