If all list are empty return one empty list else return all lists

Hi,
I’m trying to make a python node in dynamo that fixes error in my script. the purpose of the node is that when the data entering the node i all empty lists i will output one empty list, otherwise it will just return the input data. I’m doing this so that i don’t get errors when i am trying “get item at instance” later on in the script and there is no indecies in the list. The problem is that I am getting one empty list for all the lists instead of just one empty list. see picture of the problem.

i have also made one instance of the script that works, but im trying to clean it up a bit. see picture.

entering = IN[0]
elements = IN[1]

test = []
for i in entering:
	if i == None:
		test.append(True)
	else:
		test.append(False)


alltrue = all(test)

if alltrue:
	result = []
else:
	result = elements

OUT = result

here maybe:

Hi,
Thanks! Works like a charm now :slight_smile:, seems like the length check was a better way of evaluating if the list is empty or not.

1 Like