'Linked List method has non-stopping runtime
I implemented a linked list method that inserts another Linked List after a particular index and then continues with other elements that were originally after this index.
def insert_list(self, other: LinkedList, i: int) -> None:
"""
>>> linky = LinkedList([0, 1, 2, 3, 4])
>>> other = LinkedList([100, 101])
>>> linky.insert_list(other, 3)
>>> print(linky)
[0 -> 1 -> 2 -> 3 -> 100 -> 101 -> 4]
>>> print(other)
[100 -> 101]
"""
curr1 = self._first
curr2 = other._first
j = 0
while curr1 is not None:
if i == j:
after = curr1.next
while curr2 is not None:
curr1.next = curr2
curr1 = curr1.next
curr2 = curr2.next
curr1.next = after
else:
j += 1
curr1 = curr1.next
return None
But when I run my doctests they are running infinitely, I guess there is a mistake in my code. Can anyone point out what is wrong?

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
