title: How to use local variable in a function and return it?
body: <p>I am trying to create a script that sets a local variable, references it from a function, and can return the manipulated value back to the main scope (or whatever it's called; I'm new to Python)</p>
  
  <p>I have simplified my code to show the utmost basics of what I am trying to accomplish, which is to import a local from the module into a function block, I think.</p>
  
  <p>I have gotten this to work by using <code>globals</code>, but that isn't the best solution . . .</p>
  
  <pre><code>chambersinreactor = 0;
  cardsdiscarded = 0;
  
  def find_chamber_discard(): 
      """Find chambers and discard in row (reads each player slot)"""
      chambersinreactor = 0; # Resets the variable, not what I want
      cardsdiscarded = 0; # Resets the variable, not what I want
      chambersinreactor += 1
      cardsdiscarded += 1
      return # Don't know what to put here
  
  find_chamber_discard()
  
  print chambersinreactor # prints as 0, should be 1
  print cardsdiscarded    # prints as 0, should be 1
  </code></pre>