Creating one list from sub-lists based on whether it contains at least one "true"

Hi Everyone,

I have a simple issue that I simply cannot get right.

I have a list of 10 sublists, each containing 2 boolean values, as you can see at the right of the screenshot. What I need to do is create one list, of 10 boolean items from that list.

If there is at least one true in the first sublist, I need it to give me a value of true in the second final list. If they are both false, I need a false.

Any help would be greatly appreciated. I’ve tried a dozen different list nodes, in different combinations, and I just can’t get it to work!

Try this in a python script node:

import clr
from Autodesk.DesignScript.Geometry import *
input = IN[0]

outList = []

for list in input:
----if True in list:
OUT = outList

I could not put the correct identation here so just change ---- for a “Tab”


thank you for your response. I tried the Python code you show, and, when written letter for letter, the python node gives me an error.

I did, however, just a couple minutes ago, get the correct result just by the “list.ContainsItem” node.

Is there an advantage using the Python script as opposed to that? or are there downsides to achieving this with that simple node?

Thanks again

None :slight_smile:

However, you can avoid using List.Map by changing lacing to Longest

You need to link your “true/false” list of lists on the python node… You could just do it as Vikram_Subbaiah said, nothing different!

1 Like

Thank you very much!

1 Like