FAQ: Nodes: Python - Python Nodes Review

This community-built FAQ covers the “Python Nodes Review” exercise from the lesson “Nodes: Python”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

Linear Data Structures

FAQs on the exercise Python Nodes Review

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Regarding Step 3, I’m not clear why using get_link_node() is necessary

Referring specifically to the (apparently correct) code below:

dots_data = yacko.get_link_node().get_value()

Why not just write 'dots_data = yacko.link_node.get_value()? We’ve already set the link node as an attribute of the class in the set_link_node() method.

Edit: In fact, I’m not sure what the point of the get_link_node() or set_link_node() methods are at all, when we can just ‘get’ and ‘set’ using regular dot notation with class attributes.

1 Like

My best guess is that they want to expose all behaviour through methods.
I don’t agree, in my eyes it’s dead code that makes it harder to see what’s actually being done.

1 Like

I’m not sure how to complete step two. The directions are vague

1 Like

Are you referring to step 2 of page 2 or step 2 of page 4?

In this particular case you can’t tell the advantages, but the ‘get’ and ‘set’ methods are used in other programming languages in order to control the types of the data you pass to the instance variables. Say you have an instance variable ‘age’. If you didn’t set a ‘set’ method with ‘if’ statements, you would be able to enter a string. Sometimes it’s not necessary at all but people keep using the ‘set’ and ‘get’ method as good practice, I guess.

1 Like

What about the second point in step 3 (of the fourth part of the lesson)? It asks how we can get the value of -wacko- from -yacko- but they are not immediately linked. However -yacko- is linked to -dot- and -dot- is linked to -wacko-.
Is there a way to to travel through -dot- with the -.get_link_node().get_value()-?

1 Like

I don’t quite understand step 3 question. Could anyone explain the following codes:

dots_data = yacko.get_link_node().get_value()

wackos_data = dot.get_link_node().get_value()

Why do we need to use get_link_node().get_value() and when should we use this method?

Thank you in advance!


Is there a way to to travel through -dot- with the -.get_link_node().get_value()-?

The answer is yes.


If you look at the Node methods, yacko.set_link_node(dot) sets yacko.link_node = dot. When you then call the yacko.get_link_node() what’s being returned is the object dot because that’s what yacko’s link_node is assigned to. So using the second .get_link_node() in the above code is just like writing dot.get_link_node() which as you already know is is linked to wacko.


I’ll try to answer your question in a way that hopefully makes sense. The three methods we’re concerned with are:

def set_link_node(self, link_node):
    self.link_node = link_node
def get_link_node(self):
    return self.link_node
def get_value(self):
    return self.value

yacko.set_link_node(dot) #This sets yacko.link_node = dot

yacko.get_link_node() #This returns yacko.link_node which is assigned to dot

The get_value() method returns the value of the object the method is called on. So, yacko.link_node().get_value() is like writing dot.get_value() which returns the value of the object dot. This value is then assigned to the variable dots_data.

We could just get the value of the object dot directly but the idea is to obtain the value by linking nodes together. Hope this helps.


Great. Thank you so much for the detailed explanation! It was quite helpful . I greatly appreciate it.

You’re quite welcome and I’m glad it helped.

1 Like

Hello! I went around lots of discussion topics in the community forum and got here! My doubt is: WHY IS IT A BETTER APPROACH TO USE NODES AS UNDERLYING DATA STRUCTURES FOR MAKING STACKS AND QUEUES?! The Codecademy Instructions keeps asking, i have no such good reason why! Couldn’t i simply use normal Lists?!

I understood the complex way the implementation works! Is just that i need a reasonable explanation to WHY NODES (LINKED LISTS)?!

And also…Wouldn’t it be easier to do the implementation via ARRAYS?!


I think the answer is that linked-lists are being used to help you get familiar with how nodes work, but the data structures you can build with nodes can be much more complex than a simple list or an array.

Hello all,
I want to ask, are there any possibility that we can track yacko’s value from this step3 case ?

I had the same exact question and this is the answer I was looking for but I just want to work through this expression. So, the first yacko.get_link_node() basically becomes dot because we set it to that earlier, then the second .get_link_node translates to dot.get_link_node() and so we are then getting the value from dot which we set dot’s link to wackos value. Thanks for the clarity!

Thank you a lot for the clarification, I have a question, why writing dots_data = yacko.get_link_node()
wackos_data=dot.get_link_node() doesn’t return yacko.link_node or wacko.link_node when I print: print(dots_data)


I’m just not understanding the solution…why for getting dots data I need to use the methods on yacko node?

I didn’t have a problem with the exercise, but I’m still trying to understand how we would use nodes and linked lists in the real world. Does any have an Idea?