Duplicate numbers using Python Loop

Hi All, can anyone how to duplicate number in such listing for GH Python?

a = [d]*n

duplicateData.gh (11.1 KB)

Hi @Mahdiyar, that is great. Can you show me if I am keen to do the whole process in python from the raw numbers?

from ghpythonlib import treehelpers as th
a = []
for i in range(len(n)):
    a.append([i]*n[i])
a = th.list_to_tree(a)

duplicateData.gh (9.7 KB)

Legend!

Hi @Mahdiyar I am yet to familiar with GHPython Listing. Can you also show me how to code python in below example? Do we need to deal with ‘List’ and ‘Tree’ listing?? Cheers

image

from ghpythonlib import treehelpers as th
a = []
for i in range(len(n)):
    b = []
    for j in range(n[i]):
        b.append('C1_{i:02d}_{j:02d}'.format(i=i+1, j=j+1))
    a.append(b)
a = th.list_to_tree(a)
3 Likes