Select to view content in your preferred language

Confused with this error "list indices must be integers"

4015
21
Jump to solution
07-31-2012 08:34 AM
JonPedder
Deactivated User
Morning, I'm receiving this error when running a For loop "list indices must be integers". Could this be because my list is of stype string?

Here's the code. First I write values to list lMembers
rowMembers = arcpy.SearchCursor(fc6,qTeam)     lMembers = []     for z in rowMembers:         mName = z.getValue("Name")         lMembers.append(mName) 


Then I later try to write these values. Currently I'm just displaying them for debugging.
    for i in lMembers:         wMembers = lMembers         arcpy.AddMessage(lMembers)         arcpy.AddMessage(wMembers)


Not quite sure what I'm doing incorrectly

thanks in advance for you help

Jon
Tags (2)
0 Kudos
21 Replies
MathewCoyle
Honored Contributor
Remove the second string index reference to the name_field variable in your output line.
Should look like this.
txt.write("<</T({0})/V({1})>>\n".format(name_field,item))
0 Kudos
JonPedder
Deactivated User
That did get it!

Again I really appreciate your time helping me with this.

If you do get a chance to explain the loop in the next few days that'd be great.

Jon
0 Kudos