How to assign a value to next_node in the Node init method?



In this exercise, the __init__() method for the Node class takes a parameter named next_node which has a default value of None. How would a Node object be created that assigns next_node to a value?


The value provided for next_node needs to be a reference to another Node object. In most cases, a Node object is going to be created using the default value of None and then the value for self.next_node will be set as part of creating and manipulating the Node object as part of a linked list. However, the following example extends the exercise to show how a new Node object is created that will set next_node to point to the first object created.

my_node = Node(44)

my_node2 = Node(66, my_node)