# List.Insert

**URL:** <https://forum.dynamobim.com/t/list-insert/93355>\
**Category:** Packages\
**Tags:** python, dynamo\
**Created:** [August 31, 2023, 6:08am UTC](https://forum.dynamobim.com/t/list-insert/93355 "2023-08-31T06:08:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![e.cietto](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@e.cietto](https://forum.dynamobim.com/u/e.cietto)\
**Post date:** [August 31, 2023, 6:08am UTC](https://forum.dynamobim.com/t/list-insert/93355/1 "2023-08-31T06:08:50Z")

</div>

Hi everyone,  
I have trouble with lists order. As visible in the attachment I created 2 lists, the second one is divided in sublists with some of the same members of the first one.  
I found the correspondent index of each sublist of list 2 in list 1 and then used the node List.insert (I’m not an expert so I looked for AddItemto front at index nut it doesn’t exist ah ah ah ).  
I tried working on levels and lacing but still the resulting list is not the sum of the 2 as expected.  
Some one has had similar probs? Or maybe could some one tell me where the mistake could be please?

(Of course this is just an example of the issue I have with the job, it’s way larger in amount but the criticity is in here)

Thx in advance to all who would help.

 ![20_ATK_Tipo 1 con lamella Per apribili_2023-08-31_07-57-22](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/c/0c3cfd8ace7c4dac1540e227139789ae3fe55930.png)

---

<div class="post-metadata">

**Author:** ![NIRMAL](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nirmal/32/150135_2.png) [@NIRMAL](https://forum.dynamobim.com/u/NIRMAL)\
**Post date:** [August 31, 2023, 8:29am UTC](https://forum.dynamobim.com/t/list-insert/93355/2 "2023-08-31T08:29:58Z")

</div>

Hi @e.cietto  
What you want to with these two lists is a bit unclear.  
Try to share any example of the result you are expecting.

---

<div class="post-metadata">

**Author:** ![e.cietto](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@e.cietto](https://forum.dynamobim.com/u/e.cietto)\
**Post date:** [August 31, 2023, 8:58am UTC](https://forum.dynamobim.com/t/list-insert/93355/3 "2023-08-31T08:58:07Z")

</div>

![Immagine 2023-08-31 110010](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/f/dfe4f6305dda9684025a7195b2dbf5c2938df616.jpeg)  
I expect as shown

---

<div class="post-metadata">

**Author:** ![thanhdatp297GRTHP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thanhdatp297grthp/32/167370_2.png) [@thanhdatp297GRTHP](https://forum.dynamobim.com/u/thanhdatp297GRTHP)\
**Post date:** [August 31, 2023, 9:44am UTC](https://forum.dynamobim.com/t/list-insert/93355/4 "2023-08-31T09:44:14Z")

</div>

I think you want to insert the child list of under list that have the same iteam to child list of above list.  
You can try this solution

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/1/e13c6c2c338b63473d65801770f67898740cc3b0.png)  
[test1.dyn](https://forum.dynamobim.com/uploads/short-url/jTBeJu1AwhfgzDsV8Tqe4hsvQz8.dyn) (5.7 KB)

```auto
import clr

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

list1 = IN[0]
list2 = IN[1]
listout = []
for i in list1:
    for j in list2:
        if i[0]==j[0]:
            for ji in j:
                i.append(ji)
        else:
            i = i
    listout.append(i)

OUT = listout

```

---

<div class="post-metadata">

**Author:** ![stefan.gokstorp](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@stefan.gokstorp](https://forum.dynamobim.com/u/stefan.gokstorp)\
**Post date:** [August 31, 2023, 10:02am UTC](https://forum.dynamobim.com/t/list-insert/93355/5 "2023-08-31T10:02:10Z")

</div>

i was to late the python solution @thanhdatp297GRTHP posted might work better but here is my solution.

 ![Like This](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/0/80034ec19c861b3434d9bbd93d65d3851be01988.png)

---

<div class="post-metadata">

**Author:** ![gilberto.arechigaiba](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gilberto.arechigaiba/32/204980_2.png) [@gilberto.arechigaiba](https://forum.dynamobim.com/u/gilberto.arechigaiba)\
**Post date:** [August 31, 2023, 10:02am UTC](https://forum.dynamobim.com/t/list-insert/93355/6 "2023-08-31T10:02:36Z")

</div>

Hola amigo @e.cietto buenas. I always get lost when there are 3 imputs and they involve levels, but here’s an alternative, I hope this helps.

 ![List combine examples](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/4/340e0727fc335e40ec948a8a838be9f5c8cdedd2.jpeg)

---

<div class="post-metadata">

**Author:** ![e.cietto](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@e.cietto](https://forum.dynamobim.com/u/e.cietto)\
**Post date:** [August 31, 2023, 10:06am UTC](https://forum.dynamobim.com/t/list-insert/93355/7 "2023-08-31T10:06:18Z")

</div>

Exactly what I was looking for thx a lot.  
And Thank you all for your help
