Skip to content

Commit ea5e3c4

Browse files
Update singly_LinkedList.py
1 parent 31a73b4 commit ea5e3c4

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

data_structures/LinkedList/singly_LinkedList.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ class Node:#create a Node
22
def __int__(self,data):
33
self.data=data#given data
44
self.next=None#given next to None
5-
65
class Linked_List:
76
pass
87
def insert_tail(Head,data):#insert the data at tail
@@ -19,8 +18,7 @@ def insert_tail(Head,data):#insert the data at tail
1918
newNod.data = data
2019
newNod.next = None
2120
tamp.next=newNod#put the newnode into last node
22-
return Head#return first node of linked list
23-
21+
return Head#return first node of linked list
2422
def insert_head(Head,data):
2523
tamp = Head
2624
if (tamp == None):
@@ -33,20 +31,17 @@ def insert_head(Head,data):
3331
newNod.data = data
3432
newNod.next = Head#put the Head at NewNode Next
3533
Head=newNod#make a NewNode to Head
36-
return Head
37-
34+
return Head
3835
def Print(Head):#print every node data
3936
tamp=Node()
4037
tamp=Head
4138
while tamp!=None:
4239
print(tamp.data)
4340
tamp=tamp.next
44-
4541
def delete_head(Head):#delete from head
4642
if Head!=None:
4743
Head=Head.next
4844
return Head#return new Head
49-
5045
def delete_tail(Head):#delete from tail
5146
if Head!=None:
5247
tamp = Node()
@@ -55,7 +50,6 @@ def delete_tail(Head):#delete from tail
5550
tamp = tamp.next
5651
tamp.next=None#delete the last element by give next None to 2nd last Element
5752
return Head
58-
5953
def isEmpty(Head):
6054
if(Head==None):#check Head is None or Not
6155
return True#return Ture if list is empty

0 commit comments

Comments
 (0)