title: How to fix Python error: AttributeError: type object X has no attribute Y
body: <p>I'm creating a practice python file to better understand object oriented programming and I am getting the following error:</p>
  
  <pre><code>AttributeError: type object 'ID' has no attribute 'the_other_number'
  </code></pre>
  
  <p>I don't really understand why this happens because when I change the variable like below, it works just fine. I only receive an error when I try to use it in an if statement:</p>
  
  <pre><code>ID.the_other_number = 'new_value'
  </code></pre>
  
  <p>Below is my example code that I am trying to fix, any help is appreciated.</p>
  
  <pre><code>class ID():
     def __init__(self):
         self.other_number()
         pass
  
     def other_number(self):
         self.the_other_number = 3111
  
  class ID_2():
      def __init__(self):
          self.update_number()
  
      def update_number(self):
         if ID.the_other_number &gt; 4:
             print(ID.the_other_number)
  
  if __name__ == '__main__':
     ID()
     ID_2()
  </code></pre>
  
  <p>I was expecting it to understand what variable is equal to and run the if statement correctly. Also, don't try to make sense of the code, I realize the code doesn't make sense, it is simply an example.</p>