Concate lists, how?

Hello,

I try some python stuff, how can i combine lists f.e.:

A,B,C,… with 1,2,3 to A-1,B-2,C-3,…

# Phython-Standard- und DesignScript-Bibliotheken laden
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

def conc (x,y):
    total = x + "-" + y;
    return total

val = []

for x,y in zip(IN[0],str(IN[1])):
    val.append(conc(x,y))

OUT = val

with numbers it worked very well (to sum up) but how can i deal with “strings”

KR

Andreas

Any reason you can’t use the string.concat node? does this have to be within python?

You need to see from what level the data is coming.
So, instead of IN[0] it would have to be IN[0][0]

Try this

def conc (x,y):
    total = x + "-" + y;
    return total

val = []

for x,y in zip(IN[0][0],IN[1][0]):
    val.append(conc(x,str(y)))

OUT = val

the list.combine combines the list using string.concat as a rule, with the hyphen string placed in the middle.

:slight_smile: yes i could, but i learn python

2021-01-18_09h19_12

even that works! :slight_smile:

I understand, the brackeds are essential for list-Depth