1

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]

asked Jun 15, 2018 at 18:00

1 Answer 1

1

Calculate Value Documentation

Expression:

fn("%Name%")

Code Block:

def fn(name):
 if len(name) is 11:
 A = 8
 else:
 A = 9
 return name[:A]

enter image description here

answered Jun 15, 2018 at 18:29
2
  • 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 Commented Jun 15, 2018 at 19:15
  • 1
    Updated answer. Does this answer your question? You want to slice the input string based on its length? Commented Jun 18, 2018 at 13:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.