title: How to solve the Python error "NameError: name 'X' is not defined"
body: <p>This is the error :</p>
  <pre><code>Traceback (most recent call last):
  File &quot;test.py&quot;, line 27, in &lt;module&gt;
        id_check(id,gender)
  NameError: name 'gender' is not defined
  </code></pre>
  <p>And this is my simple code :</p>
  <pre><code>#!/bin/python3 
  def clear_line():
      print(&quot;\n&quot;)
  
  def id_check(id,gender):
                      
      id = input(&quot; Do you have an id? : &quot;)    
  
  
      if (id == &quot;yes&quot; ) or (id == &quot;Yes&quot;) or (id == &quot;y&quot;):
          
          id = True   
      
      elif (id == &quot;no&quot; ) or (id == &quot;No&quot;) or (id == &quot;n&quot;):
          
          print (&quot;I need your id&quot;)
                  
      else:
          print (&quot;Please respound with yes or no &quot;), 
          clear_line()
          id_check(id)
  
      gender = input(&quot; What is you gender ? &quot;)
      print (gender)
  
  id_check(id,gender) 
  </code></pre>