I am trying to populate a field with the last word in an address string using field calculator within ModelBuilder. My code takes the whole address string (1234 S Brittany Town Dr) as a parameter, then splits it into a list and returns the last item in the list:
def getSufDir( prop_location ): prop_location.strip() x = prop_location.split(' ') return x[len(x)-1]
This code works for 433 of the 37,000 records in the layer. I discovered that those 433 records have 25 characters (prop_location is a 25 character maximum field). All other records return blank. Why is this happening? These code snippets seem to work fine in IDLE, but return blank values for most records when done in Field Calculator. I have attached an image of my field calculator window for reference.
An example of an address that is failing to process is 6847 W Mesa Arch Dr.
I edited to code to:
and got an identical result.