class Node:
def __init__(self,key):
self.key = key
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def append(self,data):
if self.head == None:
self.head = Node(data)
else:
cur = self.head
while cur.next != NULL:
cur = cur.next
cur.next = Node(data)
def printval(self):
cur = self.head
while cur != NULL:
print(cur.key)
cur = cur.next
ll = LinkedList()
ll.append(4)
ll.append(3)
ll.printval()
Type your question above this line.
Course: https://www.educative.io/collection/10370001/5474278013140992
Lesson: https://www.educative.io/collection/page/10370001/5474278013140992/6585350854017024