I am unsure what syntax issue I am having with my If/Elif statement. I want to not use a column in my calculation if the value is blank. The end goal is to not have extra spaces before, after and between values.
Please be kind. I am still learning Python for scripting in ArcGIS Desktop.
Here is my Prelogic and Expression.
Prelogic:
def ifFields(SubAdd,LandM, ZipN):
if SubAdd== " ":
return "!LandmarkName! + ' ' + '('+ !ZipName! + ')'"
elif LandM== " ":
return "!SubAddress! + ' ' + '('+ !ZipName!+')'"
elif ZipN== " ":
return "!SubAddress! + ' ' + !LandmarkName!"
Expression:
ifField(!SubAddress!, !LandmarkName!, !ZipName!)
if
block, then return it at the end, it's effectively required within inline helper functions. In addition, use the values passed into the function (the !var! is not valid in the code).