Add Ordinal Letter to Cell Value

Discussion created by GEOlson86 on Oct 8, 2013
Latest reply on Oct 11, 2013 by msayler
I need to add a letter to the end of a field name that increases for the selection set.  I have two shapefiles I'm working with of mosaiced tiles.  My script selects a large tile, copies the name value, then selects the smaller tiles from the second shapefile and assigns it the copied name.  But I need each of the smaller tiles to have a letter appended on so they each have different names.  It is possible to use a variable on a list to incrementally go to the next letter?  Here's my script, and it works with just adding the letter "A" to the end.

import arcpy, os

#set map doc and the layer to be used
mxd = arcpy.mapping.MapDocument("Current")
mapLyr1 = arcpy.mapping.ListLayers(mxd, "NEW_BiState_Grid400_IowaSP") [0]
mapLyr2 = arcpy.mapping.ListLayers(mxd, "GridIndexFeatures20") [0]

#alpha will be assigned a letter to rows2 update, there are 16
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']
name = str()
searchrow = 0
rows1 = arcpy.SearchCursor(mapLyr1, "", "", "Name")
rows2 = arcpy.UpdateCursor(mapLyr2, "", "", "tile")
rows = arcpy.UpdateCursor(mapLyr2)
for row in rows1:
    name = row.getValue("Name")
    print name
    arcpy.SelectLayerByAttribute_management(mapLyr1, "NEW_SELECTION", '"FID" = %s' %searchrow)
    searchrow = searchrow + 1
    arcpy.SelectLayerByLocation_management(mapLyr2, "HAVE_THEIR_CENTER_IN", mapLyr1, 0, "ADD_TO_SELECTION")
    for row in rows2:
        row.tile = name + A
del mxd, rows, rows1, rows2, searchrow