title: UnboundLocalError While Trying to Call a Function
body: <p>I'm doing an assignment that takes a number and tells the user if it is a valid SIN number. I can't get my program to run because of this:</p>
  
  <blockquote>
    <p>UnboundLocalError: local variable 'isdigit' referenced before assignment.</p>
  </blockquote>
  
  <p>How do I fix this?</p>
  
  <pre><code>from sinmodule import is_valid
  
  def main():
      print "SIN Validator"
      print "============="
  
  
     isdigit()
  
  def isdigit():
  
      int_str = str(sinnumber)
      length = (len(int_str))        
  
      number = raw_input("Please Enter SIN (Q to quit):")
  
      while length != 8:
          print "You did not enter 'Q' or a number."
          sinnumber = raw_input("Please Enter SIN (Q to quit):")
  
      if length == 8:
          if status == True:
              print "The number",number," IS a valid SIN."
          else:
              print "The number",number,"is NOT a valid SIN."
  
      if number == "Q":
          print "Good-bye!"
  
  main()
  </code></pre>