diff --git a/Formation of Linked list.py b/Formation of Linked list.py new file mode 100644 index 0000000..840a211 --- /dev/null +++ b/Formation of Linked list.py @@ -0,0 +1,22 @@ +class Node: + def __init__(self, data): + self.data=data + self.ref=None +class LinkedList: + def __int__(self): + self.head=None + def print_ll(self): + if self.head is None: + print("Linked list is empty") + return + n=self.head + while n: + print(n.data) + n=n.ref + +node1 =Node(10) +node2=Node(2) +q1=LinkedList() +q1.head=node1 +node1.ref=node2 +q1.print_ll()