Skip to content

Commit 5100b36

Browse files
committed
update the pop_tail method to first handle when ta linked list is empty and thus throw error to eliminate having to deal with special cases after this point
1 parent dc94ae0 commit 5100b36

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

Sprint-2/implement_linked_list/linked_list.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,20 @@ def push_head(self, data):
2424

2525

2626
def pop_tail(self):
27-
if self.tail is not None:
28-
tail_node = self.tail
29-
previous = self.tail.previous
30-
self.tail = previous
31-
if self.tail is not None:
32-
self.tail.next = None
33-
else:
34-
self.head = None
35-
else:
27+
if self.tail is None:
3628
raise IndexError("Unable to remove from empty linked list")
29+
30+
# tail_node = self.tail
31+
# previous = self.tail.previous
32+
# self.tail = previous
33+
# if self.tail is not None:
34+
# self.tail.next = None
35+
# else:
36+
# self.head = None
37+
# else:
38+
3739

38-
return tail_node.data
40+
# return tail_node.data
3941

4042

4143

0 commit comments

Comments
 (0)