1

In this table I need to change the last word from field !name! using the text from field !abbreviation!

enter image description here

I was trying to use Python parser to get the text from !name! field without last word and then add !Abbreviation! field. But my expression returns an error:

!Abbreviation! = !name!.split(' ')[:-1]

Can anybody help me?

4

Here is one solution:

'{} {}'.format(' '.join(!name!.split()[:-1]), !Abbreviation!)

Explanation:

  • Your code to split all of the name except the last word was correct.
  • ' '.join... converts the list back into a string
  • '{} {}'.format... creates a new string from the the join command & the abbreviation field.

In the Field Calculator you don't put !Abbreviation! = in the expression. The destination is determined automatically by the field used to open it. I believe you want the results to go back into the name field, so open the Field Calculator from there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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