title: counting in a Linked List
body: <p>I just want to make sure that my getCount function will work, because I have no idea how to test this to make sure it works could someone tell me how I would either test this function or what I did wrong? It is supposed to count the number of times a certain object has occurred in my linked list. </p>
  
  <p>Here is the ListNode import</p>
  
  <pre><code>class ListNode(object):
  
      def __init__(self, item = None, link = None):
  
          '''creates a ListNode with the specified data value and link
          post: creates a ListNode with the specified data value and link'''
  
          self.item = item
          self.link = link
  </code></pre>
  
  <p>.</p>
  
  <pre><code>from ListNode import ListNode
  
  class LinkedList(object):
  
      #--------------------------------------------------------------
  
      def __init__(self, seq=()):
  
          """ Pre: Creates a Linked List
          Post: Creates a list containing the items in the seq=()"""
  
          if seq == ():
  
              # If there is no items to be put into the list, then it creates an empty one.
              self.head = None
  
          else:
  
              # Creates a node for the first item.
              self.head = ListNode(seq[0], None)
  
              # If there are remaining items, then they're added while keeping track of the last node.
              last = self.head
              for item in seq[1:]:
                  last.link = ListNode(item, None)
                  last = last.link
  
          self.size = len(seq)
  
      def getCount(self, position):
  
          ''' This function counts the amount of times a certain item is in the Linked List.'''
  
          count = 0
          if self.head == position:
              count = 1
          if self.head.link is None:
              return count
          return count + getCount(self.head.link, position)
  
       def __copy__(self):
  
          ''' Post: Returns a new Linked List object that is a shallow copy of self.'''
  
          a = LinkedList()
          node = self.head
          while node is not None:
              a.append(node.item)
              node = node.link
          return a
  
      #-----------------------------------------------------------------
  
      def __iter__(self):
  
          return LinkedListIterator(self.head)
  
  #---------------------------------------------------------------------
  
  class LinkedListIterator(object):
  
      #-----------------------------------------------------------------
  
      def __init__(self, head):
          self.currnode = head
  
      #-----------------------------------------------------------------
  
      def next(self):
          if self.currnode is None:
              raise StopIteration
          else:
              item = self.currnode.item
              self.currnode = self.currnode.link
              return item
  
      #-----------------------------------------------------------------
  </code></pre>
  
  <p>Hopefully I posted enough of my code for you guys to see the problem. I just want to find a way to test to see if my my count works and if it doesn't I need to know how to make it work.</p>