Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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

1 Answer

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