I'm trying to create street range labels rounded to the nearest 100 unless a street range is less than 100 I'm using "50". I have a field l_refaddr that is a string with number ranges for a street segment. If a string value has less than 3 characters i want the expression to return "50", if the length is 3, then return first character and concatenate with "00", if length is 4, first two characters and "00", if legth is 5, first three characters and "00". Here's what I wrote in the expression builder:
def FindLabel ( [l_refaddr] ):
if len( [l_refaddr]) < 3:
[l_refaddr] = "50"
elif len( [l_refaddr]) == 3:
[l_refaddr] = [l_refaddr][0]+"00"
elif len( [l_refaddr]) == 4:
[l_refaddr] = [l_refaddr][:2]+"00"
else:
[l_refaddr] = [l_refaddr][:3]+"00"
return [l_refaddr]
And this is the error I'm getting:
Any ideas what I'm missing?