I have 2 fields I need to concatenate together and add zeros and a hypen.
For Example: 0001-02
In the past this code worked :
"00{0}-0{1}".format(int(!ACONTROL!)),int(!ASECTION!))
This time I am getting an error of :
SyntaxError: unexpected EOF while parsing(<string>, line 1)
My empty field I created is a text. The AControl field is a double and the ASection field is a double.
Why is my code not working this time? What have I changed? Please help. THanks!
Solved! Go to Solution.
If you want to make it a little more robust, but slightly more complex you could use:
"{0}-{1}".format("{0}".format(int(!ACONTROL!)).zfill(4),"{0}".format(int(!ASECTION!)).zfill(2))
This will yield:
as the first suggestion will yield:
It is not something that is missing... you have a parenthesis too much:
"00{0}-0{1}".format(int(!ACONTROL!),int(!ASECTION!))
If you want to make it a little more robust, but slightly more complex you could use:
"{0}-{1}".format("{0}".format(int(!ACONTROL!)).zfill(4),"{0}".format(int(!ASECTION!)).zfill(2))
This will yield:
as the first suggestion will yield:
Thank You xander for your help. The second code worked great!!
Glad it worked!