class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def append(self, data):
if self.head is None: self.head = Node(data)
else:
new_node = Node(data)
cur = self.head
while cur.next is not None:
cur = cur.next
cur.next = new_node
node1 = Node(42)
node2 = Node(5)
node1.next = node2
node2.next = node1
list1 = LinkedList()
list1.append(node1)
list1.append(node2)
current = list1.head
while current is not None:
print(current.data)
current = current.next