Searching values of a sublist in another sublist with the same index

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!

In order to compare the lists, you need to extract the characters such as “A” or “B” from the strings in the main list. Use String.Remove node.

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.

1 Like

Do you want to check if the name contains the letter? Then you could use a String.Contains node.

If you only need to compare the 4 letters which see to repeat, use a GetItemAtIndex and use 0

Hi @umberto.carenzo ,

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.

EDIT> levels, not lacing (lapsus linguae)

Thanks a lot and sorry if i did not manage to explain my problem in an easiest way!
My only question is: why in your sublist you just have 1 false?

I did not set the lacing correctly. Notice what happens when I set the lacing of List.Contains to “longest”:

Item at index 0 is being compared to the item at index 0 only

But if you want to compare it to indexes 0, 1, 2, you need to set the lacing to “Cross Product”:

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.

1 Like

Thank you so much! You’ve been really helpful!

You’re welcome. I suggest that you remove “Solution” from my reply and wait until someone resolves the whole thing, and not just half of it.

1 Like

Here’s the first part

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

Version with a one liner

1 Like

This is brilliant. Looks like i need some Phyton knowledge to use Dynamo as it’s best, thanks a lot!

1 Like