I'm trying to find the maximum value of "CrudeRate" and its associated "State_name" using the following code:
import arcpy
arcpy.env.workspace = "C:\\"
shp = r"C:\\USCancer2000.dbf"
rows = arcpy.SearchCursor(shp)
CrudeRate = "CrudeRate"
State_name = "State_name"
out_dict = {}
for row in rows:
for C in CrudeRate:
lst = []
if row.CrudeRate == C:
lst.append(row.CrudeRate)
out_dict(C) = max(lst)
del row,rows
for CrudeRate in out_dict:
print(CrudeRate, State_name)
but when I run it I get:
SyntaxError: Can't assign to function call
What is the problem with the code? How can I fix it?
You need to use brackets instead of parenthesis when assigning a dict value.
out_dict[C] = max(lst)