Welcome to the Treehouse Community
Looking to learn something new?
Adding Nodes to a Linked List.. I am getting TypeError: object() object takes no parameters, why?
This is my code: class Node: """ An object for storing a single node of a linked list. Models two attributes - data and the link to the next node in the list
Attributes: data: Data stored in node """
data = None next_node = None
def init(self, data): self.data = data
def repr(self): return "<Node data: %s>" % self.data
class LinkedList: """ Singly linked list """
def init(self): self.head = None
def is_empty(self): return self.head == None
def size(self): """ Return the number of nodes in the list Takes 0(n) time """
current = self.head count = 0 while current: count += 1 current = current.next_node return count
Why do I get this error? TypeError: object() takes no parameters
mihran akopyanCourses Plus Student 1,904 Points
I am trying to follow your code. but for some reason, it is not formatted on my screen so it is hard to find the error within the code. is there a way to link your code in your workspace so I can take a look at it?