Skip to content

Commit

Permalink
oUpdate LinkedList.py
Browse files Browse the repository at this point in the history
Fix bug - not updating tail

Otherwise if the last element is removed then future updates to the linkedlist will be erroneous
  • Loading branch information
sarathjoseph authored and brycedrennan committed Jan 16, 2021
1 parent b27666c commit 48950f4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/Chapter 2/classes/LinkedList.py
Expand Up @@ -42,6 +42,8 @@ def removeNode(self, node_value):
else:
while(current.next != None):
if current.next.value == node_value:
if current.next == self.tail:
self.tail = current
current.next = current.next.next
break
else:
Expand Down

0 comments on commit 48950f4

Please sign in to comment.