title: How do I pass variables across functions?
body: <p>I want to pass values (as variables) between different functions.</p>
  <p>For example, I assign values to a list in one function, then I want to use that list in another function:</p>
  <pre><code>list = []
  
  def defineAList():
      list = ['1','2','3']
      print &quot;For checking purposes: in defineAList, list is&quot;,list
      return list
  
  def useTheList(list):
      print &quot;For checking purposes: in useTheList, list is&quot;,list
  
  def main():
      defineAList()
      useTheList(list)
  
  main()
  </code></pre>
  <p>I would expect this to do as follows:</p>
  <ol>
  <li>Initialize 'list' as an empty list; call main (this, at least, I know I've got right...)</li>
  <li>Within defineAList(), assign certain values into the list; then pass the new list back into main()</li>
  <li>Within main(), call useTheList(list)</li>
  <li>Since 'list' is included in the parameters of the useTheList function, I would expect that useTheList would now use the list as defined by defineAList(), NOT the empty list defined before calling main.</li>
  </ol>
  <p>However, my output is:</p>
  <pre><code>For checking purposes: in defineAList, list is ['1', '2', '3']
  For checking purposes: in useTheList, list is []
  </code></pre>
  <p>&quot;return&quot; does not do what I expected. What does it actually do? How do I take the list from defineAList() and use it within useTheList()?</p>
  <p>I don't want to use global variables.</p>