I am having trouble creating a Python expression in Field Calculator in ArcMap 10.3.1. I’m attempting to concatenate two field values (double and short integer) to a third (double) field, (CON_IN). I need to allow only two digits to be added to the system number, so if the ET_NO value is greater than or equal to 10, do not add “0”. If the ET_NO is less than or equal to 9, add “0” and the value.
The final output should look like this: 2161400187509 or 2161400187528
I’ve tried variations of this script but get basically the same results. The resulting error shows a syntax error and that SYS_NO is not defined.
Does anyone have any advice?
Pre-logic Script Code:
def Concat(x,y): x= SYS_NO y= IN_ETNO if y >= 10: return x + y elif y<= 9: return x + "0" + y
CON_IN = Concat( !SYS_NO! , !IN_ETNO! )
I see I didn't need to define the x,y. I see by the other posts that I am trying to concatenate a number and a string value, but when I remove the quotation marks on the string it just sums the SYS_NO and ET_NO values which is not what I need. I am not adding the values together, I am trying to add a two digit code to the end of a system number based on unique values for each record.