Skip to content

Commit 1638201

Browse files
authored
Update linked_list.py
Refactored the code to be concise
1 parent 2e8727d commit 1638201

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

Sprint-2/implement_linked_list/linked_list.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,7 @@ def pop_tail(self):
3333

3434
node = self.tail
3535
value = node.value
36-
37-
# Move tail backwards
38-
self.tail = node.previous
39-
40-
if self.tail is None:
41-
# List is now empty
42-
self.head = None
43-
else:
44-
self.tail.next = None
45-
46-
# Fully detach the old node (good hygiene)
47-
node.next = None
48-
node.previous = None
49-
36+
self.remove(node)
5037
return value
5138

5239
def remove(self, node):

0 commit comments

Comments
 (0)