Skip to content

Commit c4af62c

Browse files
committed
Refactor pop_tail method to streamline tail removal logic
1 parent 9a279b4 commit c4af62c

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

‎Sprint-2/implement_linked_list/linked_list.py‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,7 @@ def pop_tail(self) -> Optional[object]:
3535

3636
old_tail = self.tail
3737
value = old_tail.value
38-
39-
if self.head is self.tail:
40-
self.head = None
41-
self.tail = None
42-
else:
43-
self.tail = old_tail.previous
44-
self.tail.next = None
45-
46-
old_tail.next = None
47-
old_tail.previous = None
38+
self.remove(old_tail)
4839

4940
return value
5041

0 commit comments

Comments
 (0)