# Loop for group of list

**URL:** <https://forum.dynamobim.com/t/loop-for-group-of-list/63697>\
**Category:** Lists-Logic\
**Created:** [May 7, 2021, 9:03am UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697 "2021-05-07T09:03:46Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![MariaLauraLeonardi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marialauraleonardi/32/116254_2.png) [@MariaLauraLeonardi](https://forum.dynamobim.com/u/MariaLauraLeonardi)\
**Post date:** [May 7, 2021, 9:03am UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/1 "2021-05-07T09:03:46Z")

</div>

Hi, I have a list of list and I want to create a lop with Python which associates the first two items of each list, then the second items and so on. How can I do that?  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/3/83d83ccab8dcbf7a96f32a8c5de9a49207f65749.png)

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [May 7, 2021, 9:44am UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/2 "2021-05-07T09:44:33Z")

</div>

Hi @MariaLauraLeonardi,

You won’t need Python for task, this should do the trick:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/a/dae7c0352ce19e019ad93998191a233d6800f9c9.png)

[2021-05-07 CombineIndicesBy2.dyn](https://forum.dynamobim.com/uploads/short-url/7uFpy08X5TdzA2PEN1WllmabWsK.dyn) (12.4 KB)

Regards,  
Daan

PS: no loops needed, you almost never need loops 🙂

---

<div class="post-metadata">

**Author:** ![MariaLauraLeonardi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marialauraleonardi/32/116254_2.png) [@MariaLauraLeonardi](https://forum.dynamobim.com/u/MariaLauraLeonardi)\
**Post date:** [May 7, 2021, 9:54am UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/3 "2021-05-07T09:54:18Z")

</div>

Hi, thanks this seems amazing! The only issue is that I need  
List 0  
A1  
A2  
B1  
B2

and the foollowing list should be  
List 1  
A2  
A3  
B2  
B3

Like “concatenated” if you see my point! Is that possible?

---

<div class="post-metadata">

**Author:** ![MariaLauraLeonardi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marialauraleonardi/32/116254_2.png) [@MariaLauraLeonardi](https://forum.dynamobim.com/u/MariaLauraLeonardi)\
**Post date:** [May 7, 2021, 10:22am UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/4 "2021-05-07T10:22:39Z")

</div>

and also @Daan other problem is that when i combine them it combines me the first with the last and not the two consecutives

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/59807c6d0e23a2b66a55b78fc162da47d24101dc.png)  
while basically I need these groups (Like in the example but 4 the entire wall)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/c/8c6c1b2dda005319fb959c9f205b8324919a28a7.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 7, 2021, 12:22pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/5 "2021-05-07T12:22:17Z")

</div>

List.TakeItems with proper lacing and list levels will do the trick for the first list.

List.DropItems and then a List.Flatten both woth proper lacing and list levels would work well for the second.

Finally a List.Create will put the two lists into one.

---

<div class="post-metadata">

**Author:** ![MariaLauraLeonardi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marialauraleonardi/32/116254_2.png) [@MariaLauraLeonardi](https://forum.dynamobim.com/u/MariaLauraLeonardi)\
**Post date:** [May 7, 2021, 12:45pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/6 "2021-05-07T12:45:47Z")

</div>

@jacob.small I have more than two lists, thus should I manually do that everytime? Can you please give me an example

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 7, 2021, 1:33pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/7 "2021-05-07T13:33:47Z")

</div>

Give this a try. I think it’s the output you’re looking for, but we’re getting dangerously high list levels here. 😁

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/6/0663677a49e1d3028b457362a20df0ce4d99366b.png)  
I only shifted indices once so you just get couplets instead of quads, but you should be able to continue this logic with two more index shifts to get the other sets of points.

---

<div class="post-metadata">

**Author:** ![MariaLauraLeonardi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marialauraleonardi/32/116254_2.png) [@MariaLauraLeonardi](https://forum.dynamobim.com/u/MariaLauraLeonardi)\
**Post date:** [May 7, 2021, 1:38pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/8 "2021-05-07T13:38:58Z")

</div>

I’m gonna try 😃 yes im extremely scared but this level of listing ahhahah 🤣 😅 😭

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 7, 2021, 1:40pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/9 "2021-05-07T13:40:31Z")

</div>

I’d also recommend installing LunchBox if you haven’t already. It has a node for locating quad panels/points that does exactly what you’re looking for. It’ll be **much** easier.

---

<div class="post-metadata">

**Author:** ![MariaLauraLeonardi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marialauraleonardi/32/116254_2.png) [@MariaLauraLeonardi](https://forum.dynamobim.com/u/MariaLauraLeonardi)\
**Post date:** [May 7, 2021, 1:42pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/10 "2021-05-07T13:42:07Z")

</div>

wait wait wait, I have LunchBox 😃 do you remember the name of this node?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 7, 2021, 1:47pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/11 "2021-05-07T13:47:35Z")

</div>

`Panel.PanelQuad`. You’ll need to convert your points to UV parameters on the surface first, but that’s straightforward with `Surface.UVParameterAtPoint`.

---

<div class="post-metadata">

**Author:** ![MariaLauraLeonardi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marialauraleonardi/32/116254_2.png) [@MariaLauraLeonardi](https://forum.dynamobim.com/u/MariaLauraLeonardi)\
**Post date:** [May 7, 2021, 1:54pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/12 "2021-05-07T13:54:39Z")

</div>

@Nick_Boyts So i should create a surface before?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 7, 2021, 1:56pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/13 "2021-05-07T13:56:23Z")

</div>

It looks like you already have one from your screenshot. You just need a surface that contains those points.

---

<div class="post-metadata">

**Author:** ![MariaLauraLeonardi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marialauraleonardi/32/116254_2.png) [@MariaLauraLeonardi](https://forum.dynamobim.com/u/MariaLauraLeonardi)\
**Post date:** [May 7, 2021, 3:05pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/14 "2021-05-07T15:05:45Z")

</div>

Unfortunately none of this is working, since it skip some surfaces. Couldn’t be easier a Python Script with a loop?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 7, 2021, 3:26pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/15 "2021-05-07T15:26:53Z")

</div>

Try this.

```
row = IN[0]
col = len(row[0])
r = 0
out = []

while r+1 < len(row):
	c = 0
	while c+1 < col:
		quad = [row[r][c],row[r][c+1],row[r+1][c],row[r+1][c+1]]
		out.append(quad)
		c = c+1
	r=r+1

OUT = out
```

---

<div class="post-metadata">

**Author:** ![MariaLauraLeonardi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marialauraleonardi/32/116254_2.png) [@MariaLauraLeonardi](https://forum.dynamobim.com/u/MariaLauraLeonardi)\
**Post date:** [May 7, 2021, 3:35pm UTC](https://forum.dynamobim.com/t/loop-for-group-of-list/63697/16 "2021-05-07T15:35:56Z")

</div>

Update!! It is working super good!!! Thanks a lot!!! @Nick_Boyts this is amazing
