I am practicing Python, Linked List:
class LinkedList
class LinkedList:
def init(self):
self.head = None
def __repr__(self):
node = self.head
nodes = []
while node is not None:
nodes.append(node.data)
node = node.next
nodes.append('None')
print(nodes)
return ' -> '.join(nodes)
Question:
- We all know that to point the 1st node to the 2nd node: first_node.next = second_node
- However, in the class LinkedList above, we can see: node = node.next
1/ What is the difference between them?
2/ In the class LinkedList, where is the next method from?
Thanks for your advance.