I'm stuck on my CalculateField function with how to correctly type the syntax.
I'm not particularly tied to the variables I assigned up front.
The issue is syntax for the expression.
I am currently using ArcGIS 10.3 and Python 2.7.8.
This is the line that is getting me:
arcpy.CalculateField_management(fc, "Cohort", expression="""openYear + " to " + closeYear""")
How should I be writing the expression?
expression="'str(openYear)' + " to " + 'str(closeYear)'"
The rest is a sample of my loop statement.
#################################
for fc in fcList:
openYear=fc[12:16]
closeYear=fc[20:24]
# Add "Cohort" field to *USA feature classes in scratch.mdb
print fc
arcpy.AddField_management(fc, "Cohort", "TEXT")
print "Cohort added."
# Calculate "Cohort" field to match feature class name in scratch.mdb
arcpy.CalculateField_management(fc, "Cohort", expression="""openYear + " to " + closeYear""")