FAQ: Linked Lists: Python - Linked List Implementation III


This community-built FAQ covers the “Linked List Implementation III” exercise from the lesson “Linked Lists: Python”.

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

Computer Science

Linear Data Structures

FAQs on the exercise Linked List Implementation III

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!



So I reported the bug, but the instructions for this exercise show as completed and won’t reset and no errors arise no matter what I do (I tried changing all indentation to test that error messages won’t arise), so I don’t know if my code is correct or not and since it is my first data structure, I don’t know how to check it without the instructions checking each step off. I am hoping you all can help me. I am copying my method below. I am fairly confident that up until the “else:” is correct, but I am very unsure about the rest. Thank you for any feedback!

Define your remove_node method below:

def remove_node(self, value_to_remove):
  current_node = self.get_head_node()
  if current_node.get_value() == value_to_remove:
    self.head_node = current_node.get_next_node()
    while current_node:
      current_next_node = current_node.get_next_node()
      if current_next_node == value_to_remove:
        current_node.set_next_node = next_node.get_next_node()
        current_node = None


I’m trying to understand the part where you

current_node = None

So assuming we have Head --> b --> c & b is what is being removed

So the current_node at this point is still the head node Node( #, b) then we set the current node to skip b to go to c. So now head node (current_node) is Node(#, c). Why set current_node = None when it is in fact Node(#,c).

I just answered my own question… you set current_node to None because current_node has served it’s purpose and is not needed anymore and it will send a signal to the while loop that you may stop.


I was told the reset issue is happening to only some people. I’m trying to check my code as well and the checks won’t reset.

If someone could go back and reset and post the solutions version, that would be incredibly helpful! Please!


Here is the solution:

  def remove_node(self, value_to_remove):
    current_node = self.get_head_node()
    if current_node.get_value() == value_to_remove:
      self.head_node = current_node.get_next_node()
      while current_node:
        next_node = current_node.get_next_node()
        if next_node.get_value() == value_to_remove:
          current_node = None
          current_node = next_node

I had come up with something similar but functionally the same but the checker kept asking me if I accidentally removed my remove_node() method. :man_facepalming:


These getters and setters kind of come from nowhere, with no explanation. Why are they even necessary, when the node values can be referenced directly from within their own class? I wrote the remove_node method with out any getters and setters and it works exactly the same… Looking for understanding on WHY? What is the advantage or reasoning behind the practice?

def remove_node(self, value_to_remove):
    print('Remove: ' + str(value_to_remove))
    current_node = self.head_node
    if current_node.value == value_to_remove:
      self.head_node = current_node.next_node
      while current_node:
        nxt_node = current_node.next_node
        if nxt_node.value == value_to_remove:
          current_node.next_node = nxt_node.next_node
          current_node = None
          current_node = nxt_node


Found this discussion fairly helpful:



My guess is people see that getters and setters exist and therefore assume that they are automagically useful.

Use what you can argue for.

Something that is particularly useless is having get and set behaving the same way as a plain attribute.


Did the instructions or hints mention the second else statement?


The instructors apparently learned their OOP via Java, where getters & setters are mandatory. But they’re still inconsistent, as there is no setter for head_node. That one we apparently are to access directly!


From what I seen whilst I was doing that exercise, the second else statement wasn’t mentioned in the hints and definitely not in the instructions.

This exercise has absolutely killed me, but I think I finally understand it now :slight_smile: