Skip to content

Commit 623288b

Browse files
Update linked-lists-python.py
1 parent 3c7c47c commit 623288b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

linked-lists-python/linked-lists-python.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ def add_after(self, target_node_data, new_node):
4949
raise Exception("List is empty")
5050

5151
for node in self:
52-
if node.data != target_node_data:
53-
continue
54-
new_node.next = node.next
55-
node.next = new_node
56-
return
52+
if node.data == target_node_data:
53+
new_node.next = node.next
54+
node.next = new_node
55+
return
5756

5857
raise Exception("Node with data '%s' not found" % target_node_data)
5958

0 commit comments

Comments
 (0)