Code Block to make List of String and If Statement

How do I write a Codeblock with an If Statement like this?

If InString= “Unit” Then Outstring= "Count"
If InString= “Length” Then OutString = "M"
If InString = “Area” Then OutString="M^2"
If InString="Volume then OutSting=“M^3”

How do I write a codeblock that has inputs of a number and a String that will create a list of strings the length of the number

Thanks in advance this Forum is very supportive for learners.

You’ll either have to resort to nested if statements or imperative code. Both of those solutions are sometimes difficult to interpret and modify. Consider the following example instead - lists in Dynamo can also act like dictionaries:

3 Likes

To the second part of your question, is this what you are after?

t1 = String.Length(inputString);
t3 = t1 - len;
String.Remove(inputString, len, t3);