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
1 Answer 1
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)
else
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– mikeLdub2015年03月05日 13:44:25 +00:00Commented Mar 5, 2015 at 13:44
Explore related questions
See similar questions with these tags.