Linked List

class Node:
def __init__(self,data):
self.data=data
self.next=None
class LinkedList:
def __init__(self):
self.head=None
self.tail=None
def inputLL(self,arr):
if len(arr)==0:
return
for i in arr:
NewNode=Node(i)
if self.head is None:
self.head=NewNode
self.tail=NewNode
else:
self.tail.next=NewNode
self.tail=NewNode
return self.head
def printLL(self):
if self.head is None:
return
while self.head is not None:
print(self.head.data,end=" ")
self.head=self.head.next
l=LinkedList()
arr=list(map(int,input().split()))
l.inputLL(arr)
l.printLL()
view raw 1.LinkedList.py hosted with ❤ by GitHub

Comments

Popular posts from this blog

MySQL Multi Source Master Slave Replication using GTID

Access and modify all the resources of our Wiki.js using WikiJS API

How to setup an Nginx reverse proxy with a SSL certificate in XWIKI