Using the following class definitions, write a count method for the LinkedList class,
that takes a list cargo item as an argument and returns the number of times the item
occurs in the list.
class Node:
def __init__(self, cargo=None, next=None):
self.cargo = cargo
self.next = next
def __str__(self):
return str(self.cargo)
class LinkedList:
def __init__(self):
self.length = 0
self.head = None
def addFirst(self, cargo):
node = Node(cargo)
node.next = self.head
self.head = node
self.length = self.length + 1