This is a really short script but I cannot seem to make it work in field calculator no matter what. No errors are generated but it converts all rows in the column to null values even if they are numbers (like a zip code plus 4 without the hyphen that just needs a hyphen added which is in a 10-digit Text field).
def ZipCodeFix(MyInput):
if MyInput is None:
pass
elif MyInput == '':
return None
else:
NoSpaces=MyInput.strip()
if len(NoSpaces) == 9:
output = NoSpaces[:5] + '-' + NoSpaces[5:]
return output
else:
pass