Field Calculator and python interpreter are different tools. The former post-process what you introduce as expression and should not be treated "strictly" as a python interpreter. The error message says once processed, Field Calculator tool treats your code's + "\\" + as a code line continuation character (i.e., , for more details have ...
I could easily be wrong on this one and what you're trying be valid, but I've only ever seen examples for or personally used a calculate field expression that is a single string.
As I understand it, the string provided here is passed in and then parsed, so it can contain strings itself as long as you use single quote for the outer and double for strings ...
What you are seeing is due to the fact that and takes precedence over or. a and b or c is the same as (a and b) or c and not a and (b or c), as you assumed.
As mentioned in the other answer, you can use parentheses to change the precedence (because parentheses have a higher precedence than either of and and or), or even better, use in. You can also turn your ...
This works for me
# Declare variables
# Separate the address string into parts
address_string = address_string.split()
# Traverse through the address parts
for add in address_string:
hn += add
ha += ...
Logical operator precedence and order of operators is causing your issue. Try grouping your ors in parentheses:
def Reclass(gridcode, CWHR_TYPE):
if gridcode == 1 and CWHR_TYPE == "Annual Grassland" or CWHR_TYPE == "AGS" or CWHR_TYPE == "Perennial Grassland":
return "Avena Grassland"
elif gridcode ==...
Maybe there are easier ways, but here's one using Python.
In the Field Calculator window, select the Python parser
Check Show Codeblock
The Pre-logic Script code defines a method that returns only values greater than 0.
def greater_than_0 (value):
return value > 0
The code for the MIN field is
min (filter (greater_than_0, [ !FromLeft!, !FromRight!,...