Insert in a list

hello everyone
thanks for your helping
i try to insert three values in a list. but its inserting only one value.

Hello, here is a solution
take a good look at your incoming students (you have help)
Often programmers are nice to us
don’t forget it
(The translated sentence is:)
Indicates the location where to insert the item in the list
I want an integer (int)


Cordially
christian.stan

thanks for you reply.
Actually I want to insert different values in different index places.

1 Like

Sorry, that’s beyond my skills.
I would do a list split and reassemble in this case.
Cordially
christian.stan

1 Like

I realized via python (necessarily improvable) but it must be possible in classic nodes


Python script:

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

for i,j in zip(IN[2],range(len(IN[2]))):
    IN[0][0].insert(i,IN[1][j])

OUT = IN[0]

edit: fixed my problem with increment relative to initial list

for i,j in zip(IN[2],range(len(IN[2]))):
    IN[0][0].insert(i+j,IN[1][j])

Cordially
christian.stan

Hi @sivarajann ,

Adding to what @christian.stan suggested: you will have to use Python for this.

After searching for 5 minutes on the forum I found some other topics though so if the solution proposed by Christian doesn’t work I recommend searching on “insert multiple” or something similar.

1 Like

Thanks for all
First time I am adding scripts, is it correct ? it showing some error.

Hello, your starting list depth is not the same, you have to replace the
edit:

for i,j in zip(IN[2],range(len(IN[2]))):
    IN[0].insert(i+j,IN[1])

OUT = IN[0]

edit 2 : As said by Mr. Sovitek, no need to reinvent the wire to cut the butter if already better certainly done by Mr. Alban (Genius Loci) :wink:
Cordially
christian.stan

2 Likes

Hello try this one her from genius loci is written in python as well,so you can see how it could be done…

2 Likes

thanks a lot guys
I installed genius loci, its wonderful. Can you suggest any good packages. I have the below list.
image

1 Like