Q:

Collect last word from varied length string for filtering, auto labeling and column population?

I have been looking and reading for a few days about how to collect the last word from a varied length string. I have found lots of postings about how to collect/split the last word, but none of the content I have read addresses varied length stings.
I would like to use this function for column population, automated labeling and content filtering from inside either the field calculator or label expression interfaces.
String examples: Morgan County, Johnson Parrish, John Brown County, Rick de la Rosa City, Big Wild life Area.
Output example : County, Parish, City, Area
Nothing I have tried has worked 100%. The following code just about works, and would work if all my strings were two words long:  s.split( " " )[1:][0]
I am using arcmap 10.2 / python

A:

You are missing a very little detail: the fact that in Python you can pull elements from a list starting at the back. The last element of a list corresponds to index -1.
For example:
location = "Cedar Wood Park"
locationChoppped = location.split(" ")
print locationChoppped[-1]

would return: Park, and:
location = "Highland Grove Hyper Megalopolis"
locationChoppped = location.split(" ")
print locationChoppped[-1]

would return: Megalopolis
Or, all in one line, and using s instead of location, like in your question:
s.split(" ")[-1]

PS: to actually use this in ArcGIS, you would have to right-click your new field in the attribute table and open the Field Calculator. Make sure to select Python and check the Pre-Logic Script Code box. Then enter:
def returnLastElement(s):
    return s.split(" ")[-1]

This would create a function. Then, in the narrow block below, you can call that function. Just repeat the name and call the field which you want to pass to your function and whose values should be truncated. Make sure to embrace the field name by exclamation points (!), or it will not work, such as this:
returnLastElement(!TheFieldWithLongNames!)

The safest is always to just place your cursor in between the parentheses and then double-click your field in the list above, which will then correctly insert it for you.

