From f0516be3fe307da700fc60135c3edda932c47827 Mon Sep 17 00:00:00 2001 From: Harsh <90236987+Lancelot03@users.noreply.github.com> Date: Wed, 20 Jul 2022 23:43:34 +0530 Subject: [PATCH] Create Formation of Linked list.py --- Formation of Linked list.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Formation of Linked list.py 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()