I am attempting to populate fields on two different feature classes with different strings that I have stored in a list. I would like to just put the strings and feature classes into a for loop, but it has not been working. Here is my current script that makes the most sense to me:
def protectedlandslayer(PAD, NCED, counties, protectedFC): # set local variables in lists to prepare for looping ProtectedLands = [PAD, NCED] layers = ["pad", "nced"] county_lyr = arcpy.MakeFeatureLayer_management(counties, "counties_lyr") # select protected lands that intersect PA county boundaries and copy - populate # list with output feature classes to use in add field loop temp_featureclasses =  for FC, layer in zip(ProtectedLands, layers): outFC = "in_memory" + "\\" + layer layer1 = arcpy.MakeFeatureLayer_management(FC, layer) selection = arcpy.SelectLayerByLocation_management(layer1, "INTERSECT", county_lyr) protected_fc = arcpy.CopyFeatures_management(selection, outFC) temp_featureclasses.append(protected_fc) # add field to each dataset and populate with data source for name, f in zip(layers, temp_featureclasses): arcpy.AddField_management(f, "data_src", "TEXT", "", "", 4, "Data Source", "", "", "") expression = str(name) arcpy.CalculateField_management(f, "data_src", expression, "PYTHON_9.3")
With this script, I am getting the following error:
ExecuteError: ERROR 000539: Error running expression: n Traceback (most recent call last): File "<expression>", line 1, in <module> NameError: name 'n' is not defined Failed to execute (CalculateField)
Can anyone help me out?