I'm pretty new to Python and this is my first post on this forum so I could use some help. I am currently attempting to run some code in the Field Calculator in a model in order to replace string characters (hyphen, period, space) with an underscore ('_'). Here's what I have now.
def customReplace(Layer):
repList = ['-', ' ', '.'];
rep = '_'
for repList in Layer:
return Layer.replace(repList, rep)
else:
return Layer
Im getting a syntax error: ERROR 000539: SyntaxError: unexpected EOF while parsing (, line 1) Failed to execute (Calculate Field (2)).
Anybody out there give me a hand?
By the way, I defined the above function in the pre-logic script code area and I'm calling it via
customReplace( !Layer! )