Skip to content

Commit 240acd1

Browse files
committed
edited else-if to elif
1 parent fb53ab8 commit 240acd1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

data_structures/binary_tree/avl_tree.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,11 @@ def del_node(root: MyNode, data: Any) -> MyNode | None:
220220
return root
221221
else:
222222
root.set_left(del_node(left_child, data))
223+
elif right_child is None:
224+
print(f"No such data ({data}) exists in the right subtree.")
225+
return root
223226
else:
224-
if right_child is None:
225-
print(f"No such data ({data}) exists in the right subtree.")
226-
return root
227-
else:
228-
root.set_right(del_node(right_child, data))
227+
root.set_right(del_node(right_child, data))
229228

230229
# Update the height of the node
231230
root.set_height(

0 commit comments

Comments
 (0)