Hello I would like to achieve this node of dynamo in python
I got a flatten list with another list with number of times to repeat each index of the flatten list, so the result is sublists with repeated items, for example:
thanks
Hello I would like to achieve this node of dynamo in python
I got a flatten list with another list with number of times to repeat each index of the flatten list, so the result is sublists with repeated items, for example:
thanks
it does not work because asking a number in the range and I put a list of numbers
@ruben.romero can you show your list structure?
A slight alteration to @EdsonMatt appraoch:
import sys
i = "item"
a = [1,5,1,4]
OUT = [[itm]*n for itm,n in zip([i] * len(a),a)]
Generally you’ll need to iterate (for x in listobject) if you wan’t to run any example people show you on Dynamo forums across a list object. If you’re working across lists in parallel, the zip() option is handy.
Some fairly well comprehended versions above, but this is the expanded version. I generally find these easier to read versus comprehended (essentially implied) statements ([x for x in thing]).
rptList = IN[0]
numList = IN[1]
outList = []
for rpt,num in zip(rptList,numList):
out = []
for n in range(num):
out.append(rpt)
outList.append(out)
OUT = outList
Man thanks @GavinCrump, tested and working well. Athough finally I used the @EdsonMatt single line code.