title: Calling variable defined inside one function from another function
body: <p>if I have this: </p>
  
  <pre><code>def oneFunction(lists):
      category=random.choice(list(lists.keys()))
      word=random.choice(lists[category])
  
  def anotherFunction():
      for letter in word:              #problem is here
          print("_",end=" ")
  </code></pre>
  
  <p>I have previously defined <code>lists</code>, so <code>oneFunction(lists)</code> works perfectly.</p>
  
  <p>My problem is calling <code>word</code> in line 6. I have tried to define <code>word</code> outside the first function with the same <code>word=random.choice(lists[category])</code> definition, but that makes <code>word</code> always the same, even if I call <code>oneFunction(lists)</code>.</p>
  
  <p>I want to be able to, every time I call the first function and then the second, have a different <code>word</code>.</p>
  
  <p>Can I do this without defining that <code>word</code> outside the <code>oneFunction(lists)</code>?</p>