I'm attempting to modify my feature labels such that the "NB", "SB", "WB", and "EB" portion of the string is removed:
E.g. "CEDAR AVE NB" --> "CEDAR AVE" or "ROBERT TRL S SB" --> "ROBERT TRL S"
The code I have so far is as follows (I am new to coding):
def FindLabel([StreetName]):
L = [StreetName]
L1 = L.split(" ")
if len(L1)["NB", "SB", "WB, "EB"] in L1
return L1[0] + " " + L1[1]
L1 = L
FindLabel = L
Would anyone be able to provide help? In the script, I'm looking to utilize the split method, len function and in keyword in order to break up the string into word parts, return the number of items in the string and check if the values "NB", "SB", "WB", or "EB" are present in the string, respectively.