Merry Christmas to everyone,
I'm trying this code in field calculator tool but something is wrong with python. It seems that doesn't validate the code, doesn't recognize the len and replace function as reserved words. And, when I tries to execute the tool it shows an error "2 parameters are missing or invalid".
I tried restarting the laptop, but it doesn't work.
Best regards,
Solved! Go to Solution.
your code block has to be a "def" as in the help topics
Examples of using Calculate Value—ArcGIS Pro | Documentation
modify the example to suit
txt = "a, b, c, d"
def func(val):
"""replace"""
return len(val) - len(val.replace(",", ""))
func(txt)
3
your code block has to be a "def" as in the help topics
Examples of using Calculate Value—ArcGIS Pro | Documentation
modify the example to suit
txt = "a, b, c, d"
def func(val):
"""replace"""
return len(val) - len(val.replace(",", ""))
func(txt)
3