I'm still in my infancy learning Python (also using arcpy), and I've got a field calculator expression that I am having trouble formatting. Hoping someone can help... I am using ArcMap 10.5.
I am trying to have a calculation return a value of "1" if a specific word is found in another cell (text string). So for example... A cell named "BODY_PART" contains the following string "BACK ARM LEG", I would need the expression to return a value of "1" into a new/blank field (already created) based on looking for the word "ARM".... In my mind, the equation would look something like this: If "BODYPARTS" contains "ARM" print "1" else print "0"(wrong syntax, I know).
Here is how far I got...
**in the Pre-Logic Script Code:
def findWholeWord(leg) : if 'LEG' in !BODYPARTS! : print('1') else : print('0')
This is giving me a Syntax error on Line 2.