title: Can't run multiple functions in a main function in Python
body: <p>So a problem I'm facing is this:</p>
  <p>I defined 2 functions and one function uses the variable of the other function
  Now when I run both of them using the following code, it works properly:</p>
  <pre><code>def type_anything():
      use = input(&quot;&gt;&quot;)
      return use
  
  
  def print_it():
      print(use)
  
  
  if __name__ == '__main__':
      while True:
          use = type_anything()
          print_it()
  </code></pre>
  <p>Output:</p>
  <pre><code>&gt; abcd
  abcd
  &gt; efgh
  efgh
  &gt; anything
  anything
  </code></pre>
  <p>But when I decide to make a main function that will run both the above functions and then run the main function under the &quot;<code>if __name__ ==</code> ......&quot; line, something like this:</p>
  <pre><code>def type_anything():
      use = input(&quot;&gt; &quot;)
      return use
  
  
  def print_it():
      print(use)
  
  
  def run_it():
      while True:
          use = type_anything()
          print_it()
  
  
  if __name__ == '__main__':
      run_it()
  </code></pre>
  <p>The program doesn't run properly instead shows this error:</p>
  <pre><code>&gt; anything
  Traceback (most recent call last):
    File &quot;C:/&lt;location&gt;/sample.py&quot;, line 17, in &lt;module&gt;
      run_it()
    File &quot;C:/&lt;location&gt;/sample.py&quot;, line 13, in run_it
      print_it()
    File &quot;C:/&lt;location&gt;/sample.py&quot;, line 7, in print_it
      print(use)
  NameError: name 'use' is not defined
  </code></pre>
  <p>Why is this happening? What do I need to do?</p>