I'm trying to calculate a field in Model Builder using the Calculate Field tool. I'm using the following code block and expression in the calculation, but am getting an "invalid syntax (, line 1)" error.
# Code Block: def get_block(block_id): block_only = str(block_id)[1:] if block_only[-1].isalpha(): return block_only.zfill(3) else: return block_only.zfill(2) # Expression: get_block(%block_id%)
%block_id% is an in-line substitution that points to a string variable I create as the output of a custom Python script tool. Any ideas what the error is?