title: AttributeError: 'int' object has no attribute 'get_data'
body: <p>I am having <code>AttributeError: 'int' object has no attribute 'get_data'</code> this error while testing one of my functions. The test script works alright with the sumnc_rec() function but not on rest of them. I am sharing my functions below, any suggestion to solve this problem will be of great help, Thank you.</p>
  <p>Error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;D:/CMPT 145/Assignment 7/a7q7_testing.py&quot;, line 38, in &lt;module&gt;
      output = a7q7.countnc_rec(chain, target)
    File &quot;D:\CMPT 145\Assignment 7\a7q7.py&quot;, line 36, in countnc_rec
      elif chain.get_data() == target:
  AttributeError: 'int' object has no attribute 'get_data'
  </code></pre>
  <p>Here's my code</p>
  <pre><code>import node as N
  
      def sumnc_rec(chain):
          if chain is None:
              return 0
          else:
              return chain.get_data() + sumnc_rec(chain.get_next())
      
      
      def membernc_rec(target, chain):
          if chain is None:
              return False
          elif chain.get_data() == target:
              return True
          else:
              return membernc_rec(chain.get_next(), target)
      
      
      def countnc_rec(target, chain):
          if chain is None:
              return 0
          elif chain.get_data() == target:
              return 1 + countnc_rec(target, chain.get_next())
          else:
              return countnc_rec(target, chain.get_next())
  </code></pre>
  <p>Here's the node class</p>
  <pre><code>class node(object):
  
      def __init__(self, data, next=None):
       
          self.__data = data
          self.__next = next
  
  
      def get_data(self):
  
          return self.__data
  
  
      def get_next(self):
  
          return self.__next
  
  
      def set_data(self, val):
  
          self.__data = val
  
  
      def set_next(self, val):
  
          self.__next = val
  </code></pre>