Basic linked list structure
class node:
def __init__(self,data,next=None):
self.data=data
self.next=next
class linked_list:
def __init__(self):
self.head=None
def insert(self,data):
new_node=node(data)
new_node.next=self.head
self.head=new_node
def appending(self,data):
cur = self.head
while cur.next:
cur = cur.next
cur.next=node(data)
def printing(self):
cur=self.head
while cur.next:
print(cur.data)
cur = cur.next
print(cur.data)
LL=linked_list()
LL.insert(1)
LL.appending(2)
LL.appending(3)
LL.printing()