I'm getting an ExecuteError, error 000539, in the code below when Calculating the field. The error appears to be on the second instance of fc, fc.capitalize(), because when I take out the capitalize(), I get the same error but without the capitalized name. I can't figure out what the problem is. Any ideas? Thanks.
# code
fds = 'RawFramework'
newfield = 'CountyName'
lstRawFCs = arcpy.ListFeatureClasses(None, 'All', fds)
for fc in lstRawFCs:
try:
arcpy.AddField_management(fc, newfield, 'TEXT', field_length = 25, field_alias = 'County Name')
arcpy.CalculateField_management(fc, newfield, fc.capitalize(), 'PYTHON_9.3')
except Exception as e:
print(e.message, e.__class__)
# sample error
(CalculateField).\n', <class 'arcgisscripting.ExecuteError'>)
('ERROR 000539: Error running expression: St_clair \nTraceback (most recent call last):\n File "<expression>", line 1, in <module>\nNameError: name \'San_Diego\' is not defined\n\nFailed to execute (CalculateField).\n', <class 'arcgisscripting.ExecuteError'>)