Python singly linked lists
A linked list stores each value in a node with a reference to the next node. The head identifies the first node; None marks the end.
Python
class Node:
def __init__(self, value, next_node=None):
self.value = value
self.next = next_node
head = Node(2, Node(3))
head = Node(1, head)
current = head
values = []
while current is not None:
values.append(current.value)
current = current.next
print(values)
assert values == [1, 2, 3]