[Tutor] Python List Help

Lie Ryan lie.1296 at gmail.com
Wed Oct 21 13:23:28 CEST 2009


Mike Sweany wrote:
>    33         print len(playerid)
> 
>    34         print playerid[0]
> 
>    35         
> 
> *playerid* = []
> 
> *<type 'exceptions.IndexError'>*: list index out of range
>       args = ('list index out of range',)
>       message = 'list index out of range'
> 
> If I change the print playerid[0] to print playerid[1], same error, but 
> if I change it to print playerid[2] or higher, it will show the same 
> error, but the playerid= [] will show the actual list values in the debug.

As far as I can see, playerid[0] can only fail with IndexError if 
playerid is an empty list. Have you made sure that playerid will always 
have something in it?



More information about the Tutor mailing list