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 () 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 () below!
Agree with a comment or answer? Like () to up-vote the contribution!
None is the default argument when no value is provided, so here:
node_a = Node(11, node_b)
link_node will be node_b while if we didn’t provide a default argument:
node_a = Node(11) # no argument for link_node
now link_node will be None (the default argument)
if we did:
class Node:
def __ init__(self, value, link_node):
self.value = value
self.link_node = link_node
node_a = Node(11)
we would get an error, we didn’t provide an argument/value for link_node parameter and link_node doesn’t have a default argument on which it can fallback.
in the ‘learn’ text it says:
“The node’s data will be specified when creating the node and immutable (can’t be updated). The link will be optional at initialization and can be updated.”
Is it always the case with nodes that the data is immutable and the link is mutable?
One thought the link_node is to another node, as in the next node. Why would we incorporate more structure? The default value is mutable since we can pass in a Node instance to override it. Furthermore we can set link_node at any time, either to another Node instance, or back to None when there is no next node.