Most probably there is/are white space(s) at the end of your strings. Try !Street_Name!.strip().split(" ")[:-1]
.
EDIT
I missed the colon in your slicing query. Please see below:
"xxxx yyyy".split(" ")[-1] returns--> yyyy
"xxxx yyyy".split(" ")[:-1] returns--> ['xxxx']
"xxxxyyyy".split(" ")[:-1] returns--> []
Basically, [:-1]
returns anything but the last slice ("xxxx yyyy zzzz".split()[:-1]
returns ['xxxx', 'yyyy']
) and if you have only one word in your street address, naturally it returns an empty list. I think you are looking for
!Street_Name!.strip().split(" ")[:-1] if len(!Street_Name!.strip().split(" "))>1 else !Street_Name!.strip()
!Street_Name!.split(" ")[0:-1]