K
K
Kirill Shurakov2021-07-14 18:55:50
Python
Kirill Shurakov, 2021-07-14 18:55:50

python pygame error: IndexError: list index out of range How to fix?

When the code tries to interact with this department, an error occurs IndexError: list index out of range
I have been suffering with this error for a long time and I can’t fix it in any way.

for i in range(len(Spider_right)):
for j in range(len(bullets_right)):
if Spider_right[i].colliderect(bullets_right[j]):
del Spider_right[i]
del bullets_right[j]
score += 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kingslayer, 2021-07-14
@young_programmer_kirich

in some of the indices it is necessary to put i-1 or j-1, or in several at once.
post all the code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question