1class Node:
2 def __init__(self, dataval=None):
3 self.dataval = dataval
4 self.nextval = None
5class SLinkedList:
6 def __init__(self):
7 self.headval = None
8
9# Function to add node
10 def Inbetween(self,middle_node,newdata):
11 if middle_node is None:
12 print("The mentioned node is absent")
13 return
14
15 NewNode = Node(newdata)
16 NewNode.nextval = middle_node.nextval
17 middle_node.nextval = NewNode
18
19# Print the linked list
20 def listprint(self):
21 printval = self.headval
22 while printval is not None:
23 print (printval.dataval)
24 printval = printval.nextval
25
26list = SLinkedList()
27list.headval = Node("Mon")
28e2 = Node("Tue")
29e3 = Node("Thu")
30
31list.headval.nextval = e2
32e2.nextval = e3
33
34list.Inbetween(list.headval.nextval,"Fri")
35
36list.listprint()