I noticed in the code widget that prepend class definition looped the head node; why? Is this a typo?
prepend(self, data):
if self.head is None:
new_node = Node(data)
new_node.next = self.head
self.head = new_node
I noticed in the code widget that prepend class definition looped the head node; why? Is this a typo?
prepend(self, data):
if self.head is None:
new_node = Node(data)
new_node.next = self.head
self.head = new_node