# Expect int, got List\[object\], am lost

**URL:** <https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610>\
**Category:** Developers\
**Tags:** revit, fabrication, dynamo\
**Created:** [July 23, 2019, 3:26pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610 "2019-07-23T15:26:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![L-Vettz](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@L-Vettz](https://forum.dynamobim.com/u/L-Vettz)\
**Post date:** [July 23, 2019, 3:26pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/1 "2019-07-23T15:26:01Z")

</div>

Ok friends who actually know how to code, I need some help once more.  
I have fabrication services that contain groups. These groups have an index and a name. The name can be gotten with a [GetGroupName(int) method](https://www.revitapidocs.com/2019/00ac22a9-d15d-6f9c-aefb-a2e28055dd25.htm) where the index is the int required to get the name. I have already figured out how to get my list of services, and how to get a list of the indexes for the number of groups. What I’m trying to do is get a list of the group names for each service. When I try to use the method mentioned above I can’t use the list of group indexes I have to get a list of names, as it expects a single integer. How can I do this? I read some stuff about reference arrays, but I don’t really understand them.

Basically, I have a list of services, from that I pull a list of group indexes in each service. I want to turn those indexes into names for each service using the aforementioned method, but I’m stuck.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/9/6968a49943b11f1ce8f78230a50d5b5f5fe716e7.png)

---

<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:** [July 23, 2019, 3:45pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/2 "2019-07-23T15:45:43Z")

</div>

The argument is expecting an integer but you’re giving it a list. In fact, you’re giving it a list of a list. Just like you iterate for `Item in Input` you need to iterate through your lists of GroupIDs.

---

<div class="post-metadata">

**Author:** ![L-Vettz](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@L-Vettz](https://forum.dynamobim.com/u/L-Vettz)\
**Post date:** [July 23, 2019, 3:50pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/3 "2019-07-23T15:50:12Z")

</div>

Ok. So I tried to add another iteration. It will now work if there is only once service. But if there is more than one it gives the same error. I think I’m iterating through the first list of group IDs, but like you say, it needs to go through a list of lists. Do I just add another for/in statement?

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/f/bf406c0f9052e55a95b14b0a453d4bdb4d076150.png)

---

<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:** [July 23, 2019, 4:02pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/4 "2019-07-23T16:02:13Z")

</div>

Yup! You’ll probably have to add an extra list to append to in order to keep your list structure the same.

---

<div class="post-metadata">

**Author:** ![khuzaimah.ElecEng](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/khuzaimah.eleceng/32/92768_2.png) [@khuzaimah.ElecEng](https://forum.dynamobim.com/u/khuzaimah.ElecEng)\
**Post date:** [July 23, 2019, 4:08pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/5 "2019-07-23T16:08:58Z")

</div>

can you show the input of IN[0]?

---

<div class="post-metadata">

**Author:** ![L-Vettz](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@L-Vettz](https://forum.dynamobim.com/u/L-Vettz)\
**Post date:** [July 23, 2019, 4:10pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/6 "2019-07-23T16:10:58Z")

</div>

![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/b/5b6268420b8ed83330fae5fc824c81db55970e50.png)

---

<div class="post-metadata">

**Author:** ![khuzaimah.ElecEng](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/khuzaimah.eleceng/32/92768_2.png) [@khuzaimah.ElecEng](https://forum.dynamobim.com/u/khuzaimah.ElecEng)\
**Post date:** [July 23, 2019, 4:22pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/7 "2019-07-23T16:22:06Z")

</div>

you have at the second input a list from level 3  
so you have to loop again inside the loop  
after line 10  
type  
for d in ID:  
Itemlist.append(service.GetGroupName(d))

---

<div class="post-metadata">

**Author:** ![L-Vettz](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@L-Vettz](https://forum.dynamobim.com/u/L-Vettz)\
**Post date:** [July 23, 2019, 4:38pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/8 "2019-07-23T16:38:13Z")

</div>

That didn’t do it. Now it is running the list of group indexes for all 3 services through the GetGroupName method for each service. So the number of indexes being fed into the method is larger than the number of actual groups, returning an error.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/7/47c1e1d5ee93276517eaf3bc14cec7461b90b1d5.png)

The bit of python on the right is returning “each” or what is being fed into the GetGroupName method. The list is 66 long, it should only be 22.

---

<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:** [July 23, 2019, 5:21pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/9 "2019-07-23T17:21:53Z")

</div>

Are the inputs supposed to be paired up? Does IN[0][0] go with IN[1][0] and IN[0][1] go with IN[1][1]?  
If so you’ll have to iterate through them together:  
`for Service,ID in zip(Services,GroupIDs):`

---

<div class="post-metadata">

**Author:** ![L-Vettz](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@L-Vettz](https://forum.dynamobim.com/u/L-Vettz)\
**Post date:** [July 23, 2019, 5:35pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/10 "2019-07-23T17:35:09Z")

</div>

YES. That worked. I had originally tried the zip to iterate them together, but I never had the 3rd (2nd) for/in statement that was needed to get to the individual indexes. Thanks for your help.

I don’t suppose there is a simple way to keep the original list format of the indexes on the outputs is there? This is something I can do pretty easy with regular nodes, so I’m not worried about it, but I’m trying to learn as much python as I can when I have the excuse to do so.

---

<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:** [July 23, 2019, 6:24pm UTC](https://forum.dynamobim.com/t/expect-int-got-list-object-am-lost/38610/11 "2019-07-23T18:24:39Z")

</div>

That’s what I mentioned earlier. You’ll have to append to a temporary list for each sublist of groups then append _that_ list to your output list. That’ll keep the list of list structure.
