Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Computer Science

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

    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

1 Answer

mihran akopyan
mihran akopyan
Courses 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?