fjscott

AddField_management question

Discussion created by fjscott on Mar 20, 2012
Latest reply on Mar 20, 2012 by fjscott
I need to add multiple fields based on a numerical value and would like to set this up in a for loop based on the numerical value. I have tried in the past to concatenate a string with a number, but have had no luck. As a work around, I had to add in multiple lines of code to add fields (enough to ensure that I add enough fields). As an example, this is what I would like to do:

max = 20

for i = 1 to max:
  arcpy.AddField_management(InFC, "Field_" + str(i), ...)

Something to this effect. I have tried a couple of different ways to do this in the past, but haven't had any success. Is this possible?

Thanks,

Jeremy

Outcomes