HI
I would like to know why my expression is wrong each time I added Elif statement has a Syntax error
range = Reclass(!BP_sqm!)
def Reclass (BP_sqm):
if (BP_sqm <=150):
return 150
elif (BP_sqm > 150 and BP_sqm <=300):
return 300
elif (BP_sqm > 300 and BP_sqm <=500):
return 500
elif (BP_sqm> 500 and BP_sqm <=1000):
return 1000
def Reclass(BP_sqm):
"""Provide some context"""
if (BP_sqm <= 150):
return 150
elif (BP_sqm > 150 and BP_sqm <=300):
return 300
elif (BP_sqm > 300 and BP_sqm <=500):
return 500
elif (BP_sqm> 500 and BP_sqm <=1000):
return 1000
else:
return -999
# ----- Demo
vals = [149, 299, 499, 999, 9999]
for i in vals:
print("{} -- {}".format(i, Reclass(i)))
149 -- 150
299 -- 300
499 -- 500
999 -- 1000
9999 -- -999
Greta Rocio Salas Menendez, your code is very similar to the functioning example code that Dan Patterson provided (ignoring the spacing issue from not formatting code), which makes me wonder whether you are selecting the Python Parser