In ArcGIS Pro (2.9), I have a polygon vector layer with census data. I want to use Calculate Field to create a diversity index using the values of eight fields but I keep getting TypeErrors:

ERROR 000539: Traceback (most recent call last): File "< expression>", line 1, in TypeError: unsupported operand type(s) for +: 'int' and 'list'

These eight fields I am using in my calculation are percentages of the total population for each demographic group called per_white, per_black, per_ameri_es, per_asian, per_hawnpi, per_other, per_hisp, and per_Nhisp. All of these 8 fields were created by me and given Data Type float and Numeric Format with 6 decimals. Then I used a simple calculation to populate the data in each field (e.g., the population of WHITE people in a census tract / total population in census tract = "per_white".

Here is the calculation to calculate a diversity index of the demographic data that results in the TypeError:

div_ind =
1 - ([!per_white!]^2 + [!per_black!]^2 + [!per_amer_es!]^2 + [!per_asian!]^2 + [!per_hawnpi!]^2 + [!per_other!]^2) * ([!per_hisp!]^2 + [!per_Nhisp!]^2)

I don't know Python so I'm just using the field calculator. Why am I getting the type error if all my fields used in the calculation, as well as the target Field (div_index), are formatted as float?

  • 1
    Sorry. this is from the top of my head. I cannot test it now. In python, something between square brackets is a list. Try to remove the square brackets in your expression. I think squared is **2 and not ^2 div_ind = 1 - (!per_white!**2 + !per_black!**2 + !per_amer_es!**2 + !per_asian!**2 + !per_hawnpi!**2 + !per_other!**2) * (!per_hisp!**2 + !per_Nhisp!**2)
    – ChloeG
    Feb 16, 2022 at 12:38
  • 2
    @ChloeG Exactly. ** is exponentiation, ^ is a bitwise XOR operation. w3schools.com/python/python_operators.asp.
    – Berend
    Feb 16, 2022 at 12:42
  • 1
    Thank you @Berend I didn't know that.
    – ChloeG
    Feb 16, 2022 at 14:50
  • Thanks everyone! This worked. I'm impressed with the speed and accuracy of the answer. The generosity of people like you makes GIS worthwhile!
    – ArchArchy
    Feb 16, 2022 at 16:26
  • I am glad it was useful. I will write it as a proper answer, then.
    – ChloeG
    Feb 16, 2022 at 22:12

1 Answer 1


What the error message says is that you tried to make a calculation with an integer and a list.

In python, a list is created by using square brackets. Even if your field !per_white! is a number, [!per_white!] is a list containing one element. Removing the square brackets should solve the issue.

To square a number in python, you need to use **2.

With these changes, your expression should now be:

div_ind = 1 - (!per_white!**2 + !per_black!**2 + !per_amer_es!**2 + !per_asian!**2 + !per_hawnpi!**2 + !per_other!**2) * (!per_hisp!**2 + !per_Nhisp!**2)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.