Skip to content

Commit 6e8c1ca

Browse files
committed
linked_list update
1 parent 22e3f54 commit 6e8c1ca

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

Sprint-2/implement_linked_list/linked_list.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,13 @@ def remove(self, node): # Remove the given node from the list
4141

4242
def pop_tail(self):
4343
if not self.tail:
44-
return None
44+
return None
4545

4646
old_tail = self.tail
4747
value = old_tail.value
4848

49-
if old_tail.previous:
50-
self.tail = old_tail.previous
51-
self.tail.next = None
52-
else:
53-
# Only one element
54-
self.head = None
55-
self.tail = None
49+
self.remove(old_tail) # handles pointer updates + cleanup
5650

5751
return value
52+
5853

0 commit comments

Comments
 (0)