How to Handle Variable Input List Length/Nesting in Custom Nodes (Python)

The Konrad’s function using lists comprehension:

elements = IN[0]

ProcessLists = lambda function, lists: [ProcessLists(function, item) if isinstance(item, list) else function(item) for item in lists]

sum = lambda x: x + 1

if isinstance(elements, list):
    out = ProcessLists(sum, elements)
else:
    out = sum(elements)

OUT = out

2 Likes