title: how to pass data in variables between functions
body: <p>How can I store and pass the contents of <code>r</code> from <code>main</code> to <code>two</code>? It will print <code>r</code> if I set it to a fixed value; but how do I do it with variable contents? I tried <code>random.getstate</code>/<code>setstate</code> but it was saying &quot;function object not subscriptable&quot;.</p>
  <pre><code>import random
  from random import randrange
  
  def main():
      r = random.randrange(1,13,1)
      print (r)
     
  r = random.randrange(1,13,1)
  
  
  def two():
      if r==7 or r==11:
         print (r)
      else:
         print (r)
  
  main()
  two()
  </code></pre>