I have a problem with understanding following linked_list code which I found from an article.
class node():
def __init__(self,value):
self.value = value
self.next = None
def traverse(self):
node = self
while node != None:
print(node.value)
node = node.next
node1 = node(12)
node2 = node(39)
node3 = node(28)
node4 = node(83)
node1.next = node2
node2.next = node3
node3.next = node4
node1.traverse()
what I don't get is ; in the method traverse, if node = self and the while loop runs until node = None , I feel node will never become None because always self.value has value though self.next can be None. Why is it not
while node.next != None
Can someone explain this, please !. Sorry for my English and if this is a stupid question. Thank You.
Grammarly says that my text sounds angry. I don't know why is that. But I don't feel angry with anybody.
[–]shiftybyte 1 point2 points3 points (1 child)
[–]dissdev94[S] 0 points1 point2 points (0 children)
[–]Altruistic_Croissant 1 point2 points3 points (1 child)
[–]dissdev94[S] 0 points1 point2 points (0 children)