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

DL Neil PythonList at DancesWithMice.info
Sun Jun 7 18:43:04 EDT 2020


On 8/06/20 10:38 AM, MRAB wrote:
> On 2020-06-07 23:24, DL Neil via Python-list wrote:
>> 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.
>>
> FYI, that's the same good advice that ChrisA gave yesterday in reply to 
> the same post. See the thread "Applied Data Science with Python - 
> Assignment 2.3: clicking on chart to select Y values".


Apologies @MRAB, didn't realise the duplication. I think I came to that 
thread late, noticed @Chris (and yourself?) had responded, deleted, and 
moved-on.

-- 
Regards =dn


More information about the Python-list mailing list