AnsweredAssumed Answered

python syntax error

Question asked by SC811GIS on Dec 13, 2016
Latest reply on Dec 13, 2016 by Dan_Patterson

I'm having a bit of trouble figuring out what is wrong with this script. I am trying to tell it "if there is a direction in the pdir/sdir field, concatenate the string into the field, otherwise just print the sname + typ". It says the syntax error is on line 3. Thanks.

def reclass(pdir,sdir,typ,sname):
    if (pdir == 'N'):
        return pdir + ' ' + sname + ' ' typ
    elif (pdir == 'S'):
        return pdir + ' ' + sname + ' ' typ
    elif (pdir == 'E'):
        return pdir + ' ' + sname + ' ' typ
    elif (pdir == 'W'):
        return pdir + ' ' + sname + ' ' typ
    elif (sdir == 'N'):
        return sname + ' ' typ + ' ' + sdir
    elif (sdir == 'S'):
        return sname + ' ' typ + ' ' + sdir
    elif (sdir == 'E'):
        return sname + ' ' typ + ' ' + sdir
    elif (sdir == 'W'):
        return sname + ' ' typ + ' ' + sdir
    else:
        return sname + ' ' + typ

Outcomes