Does using "while True" cause RUNTIME ERROR?

I’m trying to solve ANUMLA, but i encountered RUNTIME ERROR when i submit the code. I’m thinking this might be due to using

while True: 

It’s working fine on my system.
Here’s my code / solution

I submit the problem in both python and c++, both are giving me RUNTIME ERROR.

Any idea would be great.

Even after you’re performing del, this line is being executed in the next iteration of the while loop:

b_arr = list(s_sub[1:n+1])

You need to note that the size of the list has decreased after the previous iteration and hence, you may be crossing the bounds of your list.