Skip to content

Commit ef2eff9

Browse files
authored
Merge pull request #130 from Fittiboy/patch-1
Fix illegal list element raising wrong Exception
2 parents 1f616b5 + 83be008 commit ef2eff9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def add_last(self, node):
4545
current_node.next = node
4646

4747
def add_after(self, target_node_data, new_node):
48-
if not self.head:
48+
if self.head is None:
4949
raise Exception("List is empty")
5050

5151
for node in self:
@@ -57,7 +57,7 @@ def add_after(self, target_node_data, new_node):
5757
raise Exception("Node with data '%s' not found" % target_node_data)
5858

5959
def add_before(self, target_node_data, new_node):
60-
if not self.head:
60+
if self.head is None:
6161
raise Exception("List is empty")
6262

6363
if self.head.data == target_node_data:
@@ -74,7 +74,7 @@ def add_before(self, target_node_data, new_node):
7474
raise Exception("Node with data '%s' not found" % target_node_data)
7575

7676
def remove_node(self, target_node_data):
77-
if not self.head:
77+
if self.head is None:
7878
raise Exception("List is empty")
7979

8080
if self.head.data == target_node_data:

0 commit comments

Comments
 (0)