Search for multiple strings values in list

Here’s a solution just with nodes. I wasn’t sure whether you wanted to find names that contained one or more of the search strings, or ones that contained all of the search strings so both are there. It’s scalable, in that you can add more search strings to the list.

In the Python node, there’s a few issues:

  • When you zip the lists, you’re only comparing the first string to the first element, and so on. You need to loop first through the elements, and then loop through the search strings within the element loop
  • You’re comparing the element itself, rather than its name to the string, which will be false because they are not the same datatype
  • The equality operator == is looking for identical objects. You’re looking for a substring, so you could instead use the form if searchString in elemName: to find whether the name contains the search string

Hope this helps,
Thomas

3 Likes