Skip to content

Commit 7a292df

Browse files
committed
update pop_tail function so that the removed node's prev and next are pointing to None. This is to ensure the removed node is fully isolated and dromant.
1 parent 56786ff commit 7a292df

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sprint-2/implement_linked_list/linked_list.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ def pop_tail(self):
2929

3030
tail_node = self.tail
3131
previous = self.tail.previous
32+
3233
self.tail = previous
3334
if self.tail is not None:
3435
self.tail.next = None
3536
else:
3637
self.head = None
38+
39+
tail_node.previous = None
40+
tail_node.next = None
3741

3842
return tail_node.data
3943

0 commit comments

Comments
 (0)