Flatten sublist that contains value false

Sorry , but Can u change ur input code block please

Use this
image

Hope u get the idea now

thank you,

1 Like

@preetesh.magadum Try this:

toNestList = lambda x: x if any(isinstance(i, list) for i in x) else [x]
OUT = []

for i in toNestList(IN[0]):
	if i[0]:
		OUT.append(i)
	else:
		OUT.extend(i)
1 Like

This is my take on it, but I think Amol’s works as well - might be harder for someone to understand who isn’t familiar with lambda functions. I’m also happy whenever I can find a use for List.Map.

flatten.dyn (9.8 KB)


Thank you , Amol & Gavin

2 Likes