diff --git a/src/main/python/algorithms/datastructures/linkedlist/DoublyLinkedList.py b/src/main/python/algorithms/datastructures/linkedlist/DoublyLinkedList.py index 4435927..dc6526f 100644 --- a/src/main/python/algorithms/datastructures/linkedlist/DoublyLinkedList.py +++ b/src/main/python/algorithms/datastructures/linkedlist/DoublyLinkedList.py @@ -112,6 +112,9 @@ def addAt(self, index, data): """ if index < 0: raise Exception('index should not be negative. The value of index was: {}'.format(index)) + + if index > self.llSize: + raise Exception('index is out of bounds. The value of index was: {}'.format(index)) if index == 0: self.addFirst(data)