title: How do I assign a dictionary value to a variable in Python?
body: <p>I'm an amateur when it comes to programming, but I'm trying my hand at Python. Basically what I want to be able to do is use math on a dictionary value. The only way I could think to do it would be to assign a dictionary value to a variable, then assign the new value to the dictionary. Something like this:</p>
  
  <pre><code>my_dictionary {
      'foo' = 10,
      'bar' = 20,
      }
  
  variable = my_dictionary['foo']
  new_variable += variable
  my_dictionary['foo'] = new_variable
  </code></pre>
  
  <p>However, when I try to assign a variable this way, I get a syntax error. Is there a better and straightforward way to do this? </p>
  
  <p>EDIT: Also, I am only using this as an example. Let's say this is a block of code, not the entire program. The fact that new variable has not been declared is completely irrelevant, I just want to know how to perform math to a dictionary value. 
  Also, I am attempting to access a dictionary outside of the function I have my code in. </p>