Skip to content

Commit 1e507e2

Browse files
committed
refactor: simplify pop_tail by reusing remove method
- Replace manual pointer logic in pop_tail with a call to self.remove() - Adhere to DRY (Don't Repeat Yourself) principles - Reduce code duplication and improve maintainability
1 parent 6e4d93a commit 1e507e2

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

Sprint-2/implement_linked_list/linked_list.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,7 @@ def pop_tail(self) -> Optional[Any]:
4444

4545
value_to_return = self.tail.value
4646

47-
if self.head == self.tail:
48-
self.head = None
49-
self.tail = None
50-
51-
else:
52-
self.tail = self.tail.previous # Move tail back one
53-
self.tail.next = None # New tail lets go of the old tail
47+
self.remove(self.tail)
5448

5549
return value_to_return
5650

0 commit comments

Comments
 (0)