Expect int, got List[object], am lost

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 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.

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.

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?

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

can you show the input of IN[0]?

you have at the second input a list from level 3
so you have to loop again inside the loop
after line 10
for d in ID:

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.

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.

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):

1 Like

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.

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.