Skip to content

Commit d89e4b5

Browse files
committed
update doctests to increase coverage for data_structures/linked_list/singly_linked_list.py
1 parent 55e459b commit d89e4b5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

data_structures/linked_list/singly_linked_list.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ def insert_nth(self, index: int, data: Any) -> None:
204204
>>> linked_list.insert_nth(3, "fifth")
205205
>>> linked_list
206206
first -> fourth -> second -> fifth -> third
207+
>>> linked_list.insert_nth(-1, 'first')
208+
Traceback (most recent call last):
209+
...
210+
IndexError: list index out of range
211+
>>> linked_list.insert_nth(6, 'sixth')
212+
Traceback (most recent call last):
213+
...
214+
IndexError: list index out of range
207215
"""
208216
if not 0 <= index <= len(self):
209217
raise IndexError("list index out of range")
@@ -227,7 +235,7 @@ def print_list(self) -> None: # print every node data
227235
>>> linked_list.insert_tail("first")
228236
>>> linked_list.insert_tail("second")
229237
>>> linked_list.insert_tail("third")
230-
>>> linked_list
238+
>>> linked_list.print_list()
231239
first -> second -> third
232240
"""
233241
print(self)

0 commit comments

Comments
 (0)