0

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

asked Mar 4, 2015 at 17:31

1 Answer 1

2

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.

answered Mar 4, 2015 at 17:50
1
  • that was it! both returning the modified value in the function and the single line code work. much appreciated. Commented Mar 5, 2015 at 13:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.