In the "Calculate Value" tool I am trying to slice the inline variable (%Name%) with another variable (A) that will be a result of the length of the %Name% variable. For example if %Name% = 11 then I would like A = 8, else I would like A = 9.
"%Name%"[:A]
- What should be the syntax of the expression and the code block? enter image description here
1 Answer 1
Expression:
fn("%Name%")
Code Block:
def fn(name):
if len(name) is 11:
A = 8
else:
A = 9
return name[:A]
answered Jun 15, 2018 at 18:29
-
here is an example (with completely incorrect syntax) on what I am trying to do: if len(%Name%) = 11 then %A% = 8 else %A% = 9 end ifPaul– Paul2018年06月15日 19:15:08 +00:00Commented Jun 15, 2018 at 19:15
-
1Updated answer. Does this answer your question? You want to slice the input string based on its length?Squanchy– Squanchy2018年06月18日 13:40:31 +00:00Commented Jun 18, 2018 at 13:40