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")