Converting a list of numbers to a list of strings?


#1

Hello, I’m a newbie to python and dynamo and I am having trouble finding a clean solution to add units to a list of numbers. Is there an clean way to convert that list to a list of string based elements and then append a string to each line? The trouble I have with appending is the range of the list is dynamic and I don’t know of a way to make my unit list to stretch to the same range. Hopefully, this make sense.


#2

Not very clean, but if you add the units before you combine the lists it should work for you. Also, instead of the code block there is a built in node that will create the lists, List.Create

 


#3

Thanks! I did not know about the Rhythm nodes. The reason I used a code block for the list compilation was to drill down on the correct level prior to combination. Otherwise I would have to flatten each time. Made sense in my head to do it that way.


#4


#5

Thanks Vikram for simplifying it.

We even do not need to add separate Code Block node.

We can do it al in one go. I know Vikram must be knowing this but gave elaborated way.

Here you go, everything in one command, this is the power of DesignScript.


#6

All, thank you! That is so simple and so blatant once I see it. Must have had some logic block :slight_smile:


#7

You can do it in many ways.