From 083ce97fff39c627c29623980e3e888ca0f3083c Mon Sep 17 00:00:00 2001 From: Prasang-money <65109534+Prasang-money@users.noreply.github.com> Date: Sun, 11 Jul 2021 23:37:01 +0530 Subject: [PATCH] Update linked_list.py # Deletes all instances of given value in list. changes in that particular file when we are deleting a node in that particular case we do not need to update the prev value otherwise prev will be pointed to the deleted node. So in the updated code, we will update prev only if the current node value is not equal to the target value. and the current node will be updated at every iteration --- linked_lists/linked_list.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linked_lists/linked_list.py b/linked_lists/linked_list.py index 61b57ce..5d0c3ce 100644 --- a/linked_lists/linked_list.py +++ b/linked_lists/linked_list.py @@ -52,7 +52,8 @@ def delete(self, value): prev.set_next(current.get_next()) else: self.head_ = current.get_next() - prev = current + else + prev = current current = current.get_next() # Pushes an item on the front of the list.