indentation - Python indent error AFTER statement -
i keep getting unexpected indent error in python idle, oddly, me, it's after statement. checked in notepad++, , tried deleting spaces , manually adding 4 in, i.e. not tab. below code; error highlighted after field_value statement. suggestions appreciated
i
import arcpy, sys arcpy.env.workspace = "c:\\" shapefile = "uscancer2000.shp" field_name = "friday" #add field arcpy.addfield_management(shapefile,field_name,"long", "","","","","nullable","non_required","") cursor = arcpy.updatecursor(shapefile) row in cursor: #get value of each of our fields, , put them variables c1 = row.getvalue("cnt1") c2 = row.getvalue("cnt2") c3 = row.getvalue("cnt3") p1 = row.getvalue("pop1") p2 = row.getvalue("pop2") p3 = row.getvalue("pop3") #check missing values, assuming non-missing values greater or equal 0 try: if((min(c1,c2,c3,p1,p2,p3) < 0) or ((p1+p2+p3) == 0) ): t field_value = 0 else: field_value= 1.0 the error after field_value= 1.0
it should be
else: field_value = 1.0 * (c1+c2+c3)/(p1+p2+p3) print "done"
Comments
Post a Comment