Expression = classify(!ID_Province!, !ID_Trail!, str(!ProjSection!)) def classify(prov, trail, section): if section == "": return prov + "-" + trail else: return prov + "-" + trail + section
Solved! Go to Solution.
Expression = classify(!ID_Province!, !ID_Trail!, !ProjSection!)
def classify(prov, trail, section): if section: return prov + "-" + trail else: return prov + "-" + trail + (str(section) if section else '')
def classify(prov, trail, section): if section: # if section has any value return prov + "-" + trail + section else: # if section is empty or null or None return prov + "-" + trail
Modify your codeblock slightly. Instead of testing a certain value ("") for section, use the generic statement whether section has some value. Your code should look like this:def classify(prov, trail, section): if section: # if section has any value return prov + "-" + trail + section else: # if section is empty or null or None return prov + "-" + trail
Expression = classify(!ID_Province!, !ID_Trail!, !ProjSection!)
def classify(prov, trail, section): if section: return prov + "-" + trail else: return prov + "-" + trail + (str(section) if section else '')
Expression = classify(!ID_Province!, !ID_Trail!, !ProjSection!)
Anddef classify(prov, trail, section): if section: return prov + "-" + trail + section else: return prov + "-" + trail + (str(section) if section else '')
if value is None