Linking level depth in a custom node with python

Hello Dynamo’ers

We are wondering how you can integrate the level counter in your python script. In other words, how is it possible to make your custom node more dynamic?

Here is the example:
I have created a custom node that finds the index of a list at a certain value given.

The python script is very simple:

list = IN[0]
boolean = IN[1]
listout =
motherlist =

for x in list:
_ for y in x:_
_ if y==boolean:_
_ listout.append(i);_
_ i+=1_
_ i=0_

But I wanted to have the outcome at level 2, so I had to rewrite the python script in:

for x in list:
_ for y in x:_
_ if y==boolean:_
_ listout.append(i);_
_ i+=1_
_ motherlist.append(listout)_
_ listout =_
_ i=0_

Is there a method to create a more dynamic code that takes the levels into account?
How do you do that?

1 Like

Have a look at the post below. Could it help?

Hey Thanks.
Alas it is not very clear to me. Sorry, I am an architect, beginner in programming in Python.
Does it have to do with the Zip() function?