4

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?

Karl Knechtel
  • 56,349
  • 8
  • 83
  • 124
David Meek
  • 183
  • 1
  • 3
  • 8

1 Answers1

9

You need to use brackets instead of parenthesis when assigning a dict value.

out_dict[C] = max(lst)
aneroid
  • 12,287
  • 3
  • 38
  • 59
garnertb
  • 9,250
  • 33
  • 38