Hi @stewiegreen, and welcome to the Codecademy Forums!
In your posted code, the header line of remove_node is not indented at all. In that condition, remove_node would be interpreted as a global function, rather than as a method belonging to any class. In your actual code, is that line indented?
This line in the remove_node method does not perform its designated task, because the get_head_node method is not actually being called:
current_node = self.get_head_node
The intended method call must include parentheses, even though there are no arguments to be passed.
EDIT (September 15, 2019):
The message regarding removing your remove_node() method accidentally is actually from Codecademy’s submission correctness test (SCT) for this exercise, rather than from the Python interpreter. Though you did not remove that method, the SCT did not find a properly functioning remove_node() method, and issued a somewhat misleading message about that.
Is there any advantage to using the getter and setter methods over just referencing the class’s arguments?
For example, if you had to set a new “next_node” is there a difference between doing it like this:
new_next_node = my_node.next_node
or like this:
new_next_node = my_node.get_next_node()
Might just be a style thing, but just wondering!
Thanks!
Man, but a more suggestive error message would be appreciated!
All I can add folks is that, if this happens to you, you should just walk back to before the error and just add back the offending code a bit at a time.
may please anyone help ?
i just can’t imagine how the head node still the first node didn’t i here changed it every time in the while loop to reach the tail node so now current node is the tail node
and at the first of the method i initial the current_node to the head_node
so now head_node = current_node = tail_node
HOW CAN THE HEAD NODE STILL THE FIRST ONE
You’re not changing the list you’re traversing it.
If you’re at a node, how do you get to the next one?
Repeat until you reach the end.
Also, I would argue that your while and if are testing the same thing, or almost, because it’s wrong to test the value since the value might really be supposed to be None if it’s a list of None’s
i know i have to do that to iterate through the list , but may you please explain this
lets say our list is 2>3>4>None and current_node is equal to the head node equal to 2 so now when i write current_node = current_node.next_node isn’t that mean current_node now become 3
and in python current_node = self.head mean they are the same now and any change for one will happen to the other how the self.head still 2 ??
i got it really thank you
but here current_node = self.head i set an object to another object so what i understand that they now are the same i hope you understand my question from this code
so this lineif current_node.get_value() != None is unnecessary? because why should i prevent the method from printing the list if it’s list of None’s
and i really understood that self.head and current_node is just a pointers referring to the same object … so how the pointer works then ?
i mean if any changes to the pointer will not change the object it self , its just i made the pointer to refer to the next node but why in adding a node to the end method … after i iterate the list to reach the tail i have to set the current_node (tail) to the new_node
and now when i set it ,it will change the tail to the new node
how can pointer don’t change the object while iterating the list but when i reached my goal i can easily set it to any value i want using pointer too !!
If you draw a list on paper and point at the first cell, then move it to the next step repeatedly, then your finger is doing the same thing as your variable.
If you’re not moving your finger then you won’t leave your current location.
If you have a pen and write something in the cell then it’ll change.
Moving your finger doesn’t cause anything to change on the paper.