How to reduce a list by using Remove Item at Index

Hello, I trying to achieve something similar to @mix in the following post

However I’m looking to just reduce a list by 12 elements. In my case it’s 12 sheets but for the exercise it really doesn’t matter what the list is, the other difference is that I’m looking at text parameters to be able to select the difference between the two lists (boxed in red), and then remove the elements from the master element list (boxed green), rather than the text list. So I’m looking at the sheet numbers as a filter to differentiate between the two list, the order is important as well, as I don’t want to remove the wrong sheet. I also tried the code put forward by @Nick_Boyts but I must have done something wrong because it did work for me. In the past I have used a Boolean filter to be able to reduce a master list, but it doesn’t seem applicable here, although I have used it to illustrate the step by step process. Any help or thoughts will be appreciated.

If I understand correctly:

You want the green list to be reduced by Sheets with the name named the yellow setdifference list?

Thanks 3Pinter,

Yes, that’s correct, I have two lists, one with 19 elements and the other with 31 elements, (red set) the difference being 12 elements (yellow set), the order of the lists are different (you will see the first index of the Set Difference is located at index 8 in the ValueByNameAsString list, which the first element to be removed, then the process repeated for the remaining 11 in the SetDifference list)
The end result should be the Green List with 31 elements is reduced by the SetDifference List of 12 down to 19 elements with the order preserved in the Green list.

Did you know about the List.FilterByBoolMask node?
I think it might be exactly what you’re looking for:

I’d use a List.FilterByBoolMask too but some python to get the bool output. (Perhaps it’s possible with OOTB nodes too)

input = IN[0]
compare = IN[1]

output = []
for i in input:
	if i in compare:

OUT = output

Thanks PauLtus and 3Pinter,
Your help is gratefully received and yes, I’m aware of the FilterByBoolMask, the is issue is how do you get a mask (true/false) between the SetDifference List and ValueByNameAsString list or even a mask between the two red lists, I think that’s what the python script that Nick_Boyts came up with was doing, but when I pasted it into the purple node it didn’t work for me.

But I’ll try your (3Pinter) new suggestion.

Use List.ContainsItem between your two red nodes. This will give you a true boolean for any item in your Clear List that shows up in the sheet number list. Then you can use that list with FilterByBoolMask to separate your sheets.

Ah, yeah good one @Nick_Boyts I knew there was an OOTB-node for it.

Anyways: @r.lietz, the choice is yours. Both giving the same result.

I’d like to thank @PauLtus, @3Pinter and @Nick_Boyts for their suggestions, it enabled me to re-assess what I was looking for, and gave me some ideas of how to handle my problem, which was creating a list of views to be placed on sheets, I had a total of 135 Sheets, out of which 17 were “POWER” sheets and the trouble I was having was how to “marry” the View names which look like “HOTEL LEVEL 3 - FLOOR PLAN - POWER LAYOUT” on to Sheets which have numbers like “EL-03-11”.
The solution I came up with looks like the following image. Apologies for the delay in response, but I was lucky enough to get a short break before winter.

1 Like