From 31f055ebbdfe7217fe16efc99020b6488a33f6d7 Mon Sep 17 00:00:00 2001 From: Amirsoroush Date: Sun, 26 Mar 2023 23:19:51 +0300 Subject: [PATCH] fix bug on delete operation in doubly linkedlist --- Chapter04/delete_operation_doubly_linkedlist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter04/delete_operation_doubly_linkedlist.py b/Chapter04/delete_operation_doubly_linkedlist.py index 8bdf96d..0996fcd 100644 --- a/Chapter04/delete_operation_doubly_linkedlist.py +++ b/Chapter04/delete_operation_doubly_linkedlist.py @@ -31,9 +31,9 @@ def delete(self, data): if current is None: #List is empty print("List is empty") elif current.data == data: #Item to be deleted is found at starting of list + self.head = current.next self.head.prev = None node_deleted = True - self.head = current.next elif self.tail.data == data: #Item to be deleted is found at the end of list. self.tail = self.tail.prev