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.


  • What should be the syntax of the expression and the code block? enter image description here

Calculate Value Documentation



Code Block:

def fn(name):
    if len(name) is 11:
        A = 8
        A = 9

    return name[:A]

enter image description here

  • 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 if – Paul Jun 15 '18 at 19:15
  • 1
    Updated answer. Does this answer your question? You want to slice the input string based on its length? – Squanchy Jun 18 '18 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.