title: counting the number of values in a linked list
body: <p>There is something wrong with my <code>countInt</code> function. besides the fact that it is labelled countINT and im putting <code>'-'</code> in it as an argument. I tested the creation of my linked list and it seems to work properly. SO i feel that I can safely rule that out as an issue. However, with the NoneType object has no attribute value error, I'm not sure where I went wrong. Could someone be another set of eyes for me and help me pick out the error and guide me to correcting it? Thank you much appreciated! </p>
  
  <p>output:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "linked_list.py", line 63, in &lt;module&gt;
      print countInt(r,1)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 25, in countInt
      countInt(head.next,n)
    File "linked_list.py", line 23, in countInt
      if head.next.value == n:
  AttributeError: 'NoneType' object has no attribute 'value'
  </code></pre>
  
  <p>expected output:</p>
  
  <pre><code>2
  2
  </code></pre>
  
  <p>my code:</p>
  
  <pre><code>class Node:
      def __init__(self,value):
          self.next = None
          self.value = value
  
  def createLinkedList(root, node):
      if root.next is None:
          root.next = node
      else:
          createLinkedList(root.next, node)
  
  def countInt(head, n, count= 0):        #create a dictionary with keys as the values of the linked list and count up if the value occurs again
      count = 0
      if head.value is None:
          return None
      else:
          if head.next.value == n:
              count += 1
          countInt(head.next, n, count)
          return count
  
  
  # root
  r = Node(1)
  
  # nodes
  a = Node(4)
  b = Node(1)
  c = Node(5)
  d = Node('-')
  e = Node(4)
  f = Node(1)
  g = Node(2)
  h = Node('-')
  i = Node(8)
  j = Node(9)
  k = Node(8)
  l = Node(3)
  
  createLinkedList(r,a)
  createLinkedList(r,b)
  createLinkedList(r,c)
  createLinkedList(r,d)
  createLinkedList(r,e)
  createLinkedList(r,f)
  createLinkedList(r,g)
  createLinkedList(r,h)
  createLinkedList(r,i)
  createLinkedList(r,j)
  createLinkedList(r,k)
  createLinkedList(r,l)
  
  
  print countInt(r,1)
  print countInt(r,'-')
  </code></pre>