Please see screenshot for field calculator Python logic. I have no idea what I'm doing that's any different from this GISSE answer.

The error I receive is ERROR 000989: Python Syntax Error (invalid syntax line 3). What am I missing?

enter image description here


You're mixing returning values from a function and assignment. You have to return the modified value, not assign it to the old variable. The correct format for the pre-logic script code would be:

def mycalc(ADM2_NAME, Projects):
  if ADM2_NAME == "Bo":
    return (Projects + 1)
    return Projects

Although there is an even better (shorter) way of doing this, without using the pre-logic code. Just type in the bottom field:

(!Projects! + 1) if (!ADM2_NAME! == "Bo") else !Projects!

which increments the value of the Projects field value by 1 where the ADM2_NAME is Bo.

  • that was it! both returning the modified value in the function and the single line code work. much appreciated.
    – mikeLdub
    Mar 5 '15 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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