Am interested in combining ClASS1 and SUBCLASS1 to form the one combined class. I wrote the expression as follows "() ()" format( !CLASS1!replace(" "","" ),( !SUBCLASS1!replace(" "","" ))as shown in the Image[![field to be combined and expression] [![enter image description here] enter image description here

but after executing I get the following error message error message

  • 1
    Please always present errors as text rather than pictures.
    – PolyGeo
    Commented Jun 30, 2017 at 21:44

2 Answers 2


If spaces before or after the values in CLASS1 and SUBCLASS1 are the only issue, the expression could be simplified by using the strip method instead:

"{} {}".format(!CLASS1!.strip(), !SUBCLASS1!.strip())

As the error states, your syntax is wrong. I assume you want to replace spaces with commas. Try this line for your expression:

"{} {}".format(!CLASS1!.replace(" ",","),(!SUBCLASS1!.replace(" ",","))


Since I now see what your data looks like, I guess the .strip() option is the nicer choice. If you still want to use the .replace() function try this:

"{} {}".format(!CLASS1!.replace(" ",""),(!SUBCLASS1!.replace(" ",""))
  • Should 0 and 1 be in between the curly brackets? like this: "{0}{1}"... will still work if the curly brackets are empty?
    – Delonix R.
    Commented Jun 30, 2017 at 14:55
  • the {0} and {1} are only necessary, if you refer to the place markes in a different order. example: "{0} {1} {0}".format("A", "B") will return "A B A". so in this case they are not necessary.
    – dru87
    Commented Jun 30, 2017 at 14:57
  • @DelonixR. if no indices are used in the expression, format will use the parameters in the order they are entered.
    – Bjorn
    Commented Jun 30, 2017 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.