title: Using global variables in a function
body: <p>How do I create or use a global variable inside a function?</p>
  <p>How do I use a global variable that was defined in one function inside other functions?</p>
  <hr />
  <p><sub>Failing to use the <code>global</code> keyword where appropriate often causes <code>UnboundLocalError</code>. The precise rules for this are explained at <a href="https://stackoverflow.com/questions/370357">UnboundLocalError on local variable when reassigned after first use</a>. Generally, please close other questions as a duplicate of <em>that</em> question when an explanation is sought, and <em>this</em> question when someone simply needs to know the <code>global</code> keyword.</sub></p>