From e159bc1958f0745e51e83d2cac8c990e8606890c Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Sat, 18 May 2024 16:13:39 +0800 Subject: [PATCH] Update append_at_any_location_singly_linkedlist.py check index equal to and check count equal to index --- Chapter04/append_at_any_location_singly_linkedlist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Chapter04/append_at_any_location_singly_linkedlist.py b/Chapter04/append_at_any_location_singly_linkedlist.py index c2e1f2f..05aabe3 100644 --- a/Chapter04/append_at_any_location_singly_linkedlist.py +++ b/Chapter04/append_at_any_location_singly_linkedlist.py @@ -28,12 +28,12 @@ def append_at_a_location(self, data, index): node = Node(data) count = 1 while current: - if count == 1: + if index == 1: node.next = current self.head = node print(count) return - elif index == index: + elif count == index: node.next = current prev.next = node return