3. What will be the output of the following code that creates a singly linked list with nodes 10, 20, 30 and prints the list?
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def append(self, data):
new_node = Node(data)
if not self.head:
self.head = new_node
return
last = self.head
while last.next:
last = last.next
last.next = new_node
def print_list(self):
current = self.head
while current:
print(current.data, end=' -> ')
current = current.next
print('None')
ll = LinkedList()
ll.append(10)
ll.append(20)
ll.append(30)
ll.print_list()