4 ms·
I think you need more information about the code and what situation it's in. Illegal index presumably means trying to access part of the list that's no longer t
by joshvm 10y ago
I think you need more information about the code and what situation it's in. Illegal index presumably means trying to access part of the list that's no longer there. If it's a shared data structure, perhaps something is popping the list while another is trying to access the last element. But without anything else to go on, who knows, maybe you accidentally stored the length of the list in a data type that could overflow?
Though in the first part of the question (ignoring the next bit), is the answer anything more complex than import random; random.choice(my_list)?