Solved! Go to Solution.
import arcpy, sys, os, traceback from arcpy import env env.workspace = r"C:\Users\Drew\Desktop\Montpelier\PythonTest\PythonGDB.gdb" env.overwriteOutput = 1 fc = "dshline_Project" field = ["Layer"] valueList = [] #Use search cursor to aquire a list of unique values with arcpy.da.SearchCursor(fc, field) as cursor: for row in cursor: valueList.append(row[0]) uniqueSet = set(valueList) uniqueList = list(uniqueSet) uniqueList.sort() del cursor count = 0 name = uniqueList[count] if count < 34: outputname = env.workspace + os.sep + name arcpy.MakeFeatureLayer_management (fc, "layer") arcpy.SelectLayerByAttribute_management("layer", "NEW_SELECTION", "Layer = " + name) arcpy.CopyFeatures_management("layer", outputname) count += 1 name = uniqueList[count] else: print "Done"
while count <= lencount - 1: # the rest of your code # so that 33 - 1 = 32, the upper index 0-based limit