How to get the index of a list?

I have double checked the code and it finally works.
Now the problem is that it can’t just find part of the whole string “Level”

Capture

Change the “if item == test” to “if item in test”?

Nop :confused:

Capture

Have you tried pasting in the code I sent? I tested it out and it worked on my end.
And is there a reason you’re trying the python solution instead of the node one?

Edit: If you need to use python, this is actually a simpler method (using the test @3Pinter mentioned):

list = IN[0]
test = IN[1]
output = []
i=0
for sub in list:
	if test in sub:
		output.append(i)
	i=i+1
OUT = output

@3Pinter solution should worked. Look:index2

1 Like

Thank you guys for you help !

Hi there!
Is it possible to makes it work even when there is no list with “Level”?

And also when there are several lists that contain “Level”? :cry: :cry:

I found the solution to makes it work if it’s an “empty list”

Now lets solve the second issue :'D

But it already works with several levels … This script returns all indexes of groups that contain a word “Level”. Or do you want to get some other output that are not these indexes?

The script returns all indexes but the problem is for “replace item at index”.
in the example it returns the indexes 7 and 8 but ionly the list 7 has been replaced

You can replace the item direct on the python script, to make it more compact, like this:

Or you need those indexes?

I think I need the indexes cause it places me the whole list in the indexes 7 and 8.

I have tried to combine the 2 python script but it doesnt work when there are empty lists

I have tried to combine the 2 python scripts here but it’s not the result expected :confused:

I think now I understand your situation… You have two lists with the same number of sublists… Then you want to replace the sublist “7” in one list with the sublist “7” of the other list, right? If so, this script will solve you problem:


Sorry, I uploded the wrong picture. Now it is correct

1 Like

That Works perfectly @tiagocorradi for “Level” !! Thanks a lot!

Is there any way to make it work for several tests? Such as “Level” and “Family” at the same time?

Several%20Check

3 Likes

Works perfectly !! thanks

1 Like