From 4a57ead629cd090b4dbfe0b990fd145734c2be5e Mon Sep 17 00:00:00 2001 From: Sweta Negi Date: Tue, 28 Oct 2025 17:03:17 +0530 Subject: [PATCH] Revert "Implement node removal and sum methods in linked list" --- .../add_and_subtract_nodes_in_linked_list.py | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/python/add_and_subtract_nodes_in_linked_list.py b/python/add_and_subtract_nodes_in_linked_list.py index fa8c5a2c..48ae72b9 100644 --- a/python/add_and_subtract_nodes_in_linked_list.py +++ b/python/add_and_subtract_nodes_in_linked_list.py @@ -26,40 +26,7 @@ def subtract(self, value): while current: current.data -= value current = current.next - - #remove_nod - def remove_node(self,value): - """Remove first occurence of a node - with the given value""" - current = self.head - - #If list is empty - if not current: - print("List is empty.") - return - #If head node itself holds the value - if current.data == value: - self.head = current.next - - #If not found - if not current: - print(f"Value{value}not foundin list.") - return - - #unlink the code - prev.next = current.next - - #sum_node - def sum_nodes(self): - """Return the sum of all node vlaues""" - total = 0 - current = self.head - while current: - total +=current.data - current = current.next - return total - # Print the linked list def print_list(self): current = self.head @@ -81,10 +48,3 @@ def print_list(self): ll.subtract(5) print("After subtracting 5 from each node:") ll.print_list() - -print("/nRemoving node with value 10.") -11.remove_node(10) -11.print_list() - -print("\nSum of nodes:",11.sum_nodes()) -