Good morning to all. I’ve been trying to pull out booleans from this (i thought) pretty simple section of a script i’m developing. Basically in the “String from Object” node i have 3 sublist @L2, i have to check if the values contained in the sublists @L2 in the node “List.Contains” are contained in the corresponding sublist in the first node.
For example:
Sublist 0 in List.Contains (C,1,A,B)
I would like the output to be the same structure of String from Object (for example, Sublist 0 has 227 values) and to obtain 4 true values and 223 false value.
Thanks in advance to anyone who could give a hand!
P.S. The structure i obtained in the List.Contains mirrors perfectly the one contained in String from Object, still i obtain just false values!
The problem you are having is that it is trying to match list “objects” not the contents of those objects. So, the List Contains is looking for a list value to be “C” not a string that contains “C”. So, use a String.Contains node and see if that helps.
Following with what @Mike.Buttery suggested, you could use String.Contains to find any letter or number (as long as they’re in the string format) using the following approach:
Thanks to everyone, i’m sorry but i think i didn’t explain myself well enough, “A” “B” “C” and “1” are not letters that i’m trying to find in the different strings, they are representative of some parameters contained in the list! Here’s an easier example of what i’m trying to obtain: my desire is to obtain in the List.Contains output instead of “false,false,false,false,false ; false,false,false,false false” “true,true,true,false,false ; true,false,true,true,false”.
Sorry again if i did not manage to be clear enough.
my desire is to obtain in the List.Contains output instead of “false,false,false,false,false ; false,false,false,false false” “true,true,true,false,false ; true,false,true,true,false”.
Please try again. List.Contains output are boolean values (true/false). What other List.Contains are you thinking of?
To the one you see in the picture. Basically i would like to obtain in the List.Contains “true” in the rows of the list corresponding to the values in the List.Create below in the pic. As you can see now (referring to the first sublist with index 0) i have 5 false values, but in the List.Create i have values “1”,“2” and “3”, so i would like to have values in position 0,1,2 “true” (because in the List.Create in the upper part in the picture “1”,“2” and “3” occupy positions 0,1,2 in the first sublist).
You need to change the levels of “item” in the node List.Contains. However, it might ignore the grouping in the list.create that u use as “item” input. Other guys will help you with that.
The problem with this is that the final outut is ignoring the grouping of the second input list that you’ve created. I don’t know how to solve that, so I’m hoping others can help you.
I couldn’t get the lacing and levels for a pure Dynamo solution. Here is some python
output = []
for item in zip(IN[0], IN[1]): #Pair list for testing with tests
tests = []
for value in item[0]: #Each value in first list
tests.append(value in item[1]) # Is it in second list
output.append(tests)
OUT = output