In the nodes lesson quiz, the first question seems to imply that to create a “node class with an accessible but immutable value”, it’s enough to define a class with the following methods.
class Node: def __init__(self, value, link_node=None): self.value = value self.link_node = link_node def get_value(self): return self.value def get_link_node(self): return self.link_node def set_link_node(self, link_node): self.link_node = link_node
However, since there’s nothing stopping anyone from just, for example, doing the following,
new_node = Node(["test value", "test value2"]) new_node.value.append("test value3") print(new_node.value) #output: ["test value", "test value2", "test value3"]
then what is actually immutable about it? Is there something I’m missing, or does the answer not really deliver on the question’s expectation?