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 Introduction to Data Structures Building a Linked List Adding Nodes to a Linked List

Eva Feng
Eva Feng
1,810 Points

Problem with class Node

When I ran the code in this video the console shows TypeError: Node() takes no arguments

Why is that?

2 Answers

Steven Parker
Steven Parker
243,228 Points

It sounds like you may have an error in the definition of the __init__ method in class Node.

If you need help with finding it, share your workspace with us so we can take a look.
Here's a video about sharing a snapshot of your workspace.

Eva Feng
Eva Feng
1,810 Points

Thank you Steven. Here is my workspace. Would be grateful if you can take a look.

https://w.trhou.se/5ohdvscewe

Steven Parker
Steven Parker
243,228 Points

When I run your code in the workspace, I get no errors. Exactly how are you running it?

Eva Feng
Eva Feng
1,810 Points

By typing the following in console: python -i linked_list.py

and error message will show up saying Node() takes no arguments. Could it be the set up of my PC?

Laura Coronel
seal-mask
.a{fill-rule:evenodd;}techdegree
Laura Coronel
Treehouse Teacher

Hi Eva Feng,

I see the issue — lines 10 to 14 need to be indented. Python is very particular about indentation, and right now, your init and repr methods are not part of the Node class because they’re aligned at the same level as the class definition.

Once you indent lines 10 to 14 so they’re inside the class, the error should go away.