Untitled
unknown
plain_text
2 years ago
485 B
16
Indexable
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = Node()
def append(self, data):
new_node = Node(data)
cur = self.head
while cur.next != None:
cur = cur.next
cur.next = new_node
node1 = Node(42)
node2 = Node(5)
node1.next = node2
node2.next = node1
list1 = LinkedList()
print(list1.append(node1))Editor is loading...