title: How to fix "NameError: name method-name is not defined"?
body: <p>I'm having trouble with the following Python code:</p>
  <pre><code>class Methods:
  
      def method1(n):
          #method1 code
  
      def method2(N):
          #some method2 code
              for number in method1(1):
                  #more method2 code
  
  def main():
      m = Methods
      for number in m.method2(4):
              #conditional code goes here
  
  if __name__ == '__main__':
      main()
  </code></pre>
  <p>When I run this code, I get</p>
  <blockquote>
  <p>NameError: name 'method1' is not defined.</p>
  </blockquote>
  <p>How do I resolve this error?</p>