From 14b0dca25e1a1f6ba0a14f483c90f7f06086efee Mon Sep 17 00:00:00 2001 From: Amirsoroush Date: Wed, 15 Mar 2023 22:07:29 +0400 Subject: [PATCH] fixes #7;Chapter04 - implementation of 'append_at_a_location' --- Chapter04/append_at_any_location_singly_linkedlist.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Chapter04/append_at_any_location_singly_linkedlist.py b/Chapter04/append_at_any_location_singly_linkedlist.py index c2e1f2f..fa8d1b7 100644 --- a/Chapter04/append_at_any_location_singly_linkedlist.py +++ b/Chapter04/append_at_any_location_singly_linkedlist.py @@ -28,19 +28,19 @@ 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 count += 1 prev = current current = current.next - if count < index: + if count <= index: print("The list has less number of elements")