[Tutor] Iterating with Range

Zak Arntson zak at harlekin-maus.com
Wed Dec 3 17:19:07 EST 2003


[SNIP]
> -----------------
>                     i=0
>                     for i in range(len(parameters[2])):
>                         port.write(parameters[2][i])
[SNIP!]
> The error I get is this:
>
> Traceback (most recent call last):
>   File "F:\wxComTool9.5.py", line 1638, in CommandCallback
>     self.SendCommand(self.selection, self.arguments)
>   File "F:\wxComTool9.5.py", line 145, in SendCommand
>     self.ProcessCommand(command, parameters)
>   File "F:\wxComTool9.5.py", line 1295, in ProcessCommand
>     for i in range(len(parameters[2])):
> IndexError: list index out of range
>
> I just don't see a problem (other than the error that I keep getting! ;-)
> )
>
> --vicki

Double-check your parameters variable. It looks like it's got less than 3
elements. You may have slipped up and meant "2nd element in parameter,"
which would be parameter[1].

---
Zak Arntson
www.harlekin-maus.com - Games - Lots of 'em



More information about the Tutor mailing list