Match Lists

I need to match the strings that come from Elements.GetParameter and those that I indicate in Python. I need to result in a Boolean variable for each string, but it is only returning one.
What can I do?

What can I do?

@Behling See if this helps:
image

out = []
searchList = ["Plan","Elevation"]

for string in IN[0]:
	if string in searchList:
		out.append(True)
	else:
		out.append(False)

OUT = out
1 Like

You can also do it this way :slight_smile:

titles = IN[0]
searchList = IN[1]

if not isinstance(titles, list):
    titles = [titles]

OUT = [True if item in searchList else False for item in titles]

What this does is as follows:

  1. Creates a new variable name for both the titles and searchList
  2. Checks if the input is an instance of the element list and if not, makes it a list
  3. Then uses a List Comprehension to return true if any item in the list matches the searchList and if not, returns false instead, appended to the OUT variable
2 Likes