I am trying to use field calculator to calculate a field based on unique types in another field. I had to go for a for loop to add new values. I have 81 classes and every class should be assigned an unique number. I am getting some error in my method. I do not have prior experience of using python code in field calculator. I am sharing my code blocks.

def u_biotope(x):
    for i in u:
        btype = count
    return listbt
u_biotope( [BIOT1] )

It shows: A field was not found or unbalanced quotation marks

does anyone have any idea, How could I solve this?

1 Answer 1


In the field calculator, your parser should be set to Python. With "Show Codeblock" checked, your function definition should go in the "Pre-Logic Script Code" and the expression box at the bottom should be populated with:


Your code block should end with the return function as well.

The "Calculate Ranges" example on the ArcGIS help page lays out the python syntax for Calculate Field relatively well.

Your Answer

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

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