Button press event - event handling and picking: IndexError: list index out of range

DL Neil PythonList at DancesWithMice.info
Sun Jun 7 18:24:22 EDT 2020


On 8/06/20 7:06 AM, Caledonian26 wrote:
...

> However, I keep getting the error: IndexError: list index out of range. Could anyone give me a helping hand as to where I am going wrong?


When things go wrong, Python tries to be helpful by providing a 
"traceback". Please copy-paste the entire traceback, to help us help you.

The error-message says that (somewhere) a list is being used *but* the 
index is pointing to an element that does not exist, eg the fifth 
element of a list that contains only three members.

Short answer: What you could do, is add a temporary print() to show you 
the exact value of the list index. Thus, giving you a pointer/where to 
back-track, to find the source of the problem...

The longer answer: learning to use a debugger or a 'visual' IDE/web-tool.
-- 
Regards =dn


More information about the Python-list mailing list