Get Indices of repetitive elements from a list

I have 2 lists “list 1” “list 2” I want to get indices of “0” from “list 2” and by using those values I want to get the values from list1

list1 = [50,45,40,35,30,25,20,15,10,5]
list2 = [0,0,5,1,1,0,3,0,1,1]

Expecting Output
output = [50,45,25,15]

But the problem is I can get the indices of all “0” from list2

I would like to know how to get the indices for duplicate elements

Thank you

The index method will only return the first found index. So, when you append list2.index(0) to your indexnumber list, it will always append 0, since that is the first index of that value in list2. However, you don’t necessarily need to know the index at all. Here is an alternative method to achieve the same thing:

Indexes.dyn (7.4 KB)

Essentially, this takes each list an associates their respective values at the same index through a zip() function. Where the second value is equal to 0, it will append the first value to a new list subset.

This can be done in nodes/codeblock form pretty easily too.

GroupByKey would work for this as well, see the blue group in the above image.