I made a Python script tool and to finish my script I want to perform a percentage calculation using the 2 results from my search cursors. And the print the result to screen.
Here's what I have (but not working):
# Run search cursor on areas with slope code 3
with arcpy.da.SearchCursor(shapecalc_input, ['POLY_AREA'], "SlopeCode in (3)") as cur1:
sum = 0
for row in cur1:
sum += row[0]
arcpy.AddMessage(sum)
# Run search cursor on areas with slope code 1 and 2
with arcpy.da.SearchCursor(shapecalc_input, ['POLY_AREA'], "SlopeCode in (1, 2)") as cur2:
sum = 0
for row in cur2:
sum += row[0]
arcpy.AddMessage(sum)
arcpy.AddMessage((cur1/cur2)*100)
My search cursors give me the right values, just the calculation isn't working (last line).
Is my syntax wrong? or should I be using a different method completely? I'm new to Python.