title: Python “NameError: Global name ”nameCheck“ is not defined.”
body: <p>I am new to python and have been practicing on Classes and methods. When I ran the script containing the code below, I get the error "NameError: Global name "nameCheck" is not defined." How can I fix it? Thanks in advance.</p>
  
  <pre><code>class game(object):
      def play(): 
           name = input("What's your name, my friend? ")
           check = nameCheck(name)
  
           if check == 1:
               print ("Hello %r " %(name))
           else:
               print ("Sorry, I can't print your name because you don't have one!")
  
  
      def nameCheck(name):
           if name == "":
               print("I can't believe you have no name!")
               return 0
  
           else:
               print("%s is a nice name!" %name)
               return 1
  game.play()
  </code></pre>
  
  <p>Python “NameError: Global name ”nameCheck“ is not defined.”</p>