Replace every 2nd item in list

Hi,

what’s the input to tell List.ReplaceItemAtIndex+ to swap every 2nd item in the target list?

Thanks!


Maybe some insperation!

I was able to figure it out with this code block, but thanks anyway @Draxl_Andreas

It’s hard knowing which Dynamo nodes will take recursive lists.

3 Likes

You should use a custom python node

l = []
c = 0
for i in IN[0]:
    if c == 0:
        l.append(i)
       c += 1
    if c == 1:
        l.append(i <= put whatever you want to replace here)
        c = 0

OUT = l
2 Likes

If I had time to learn Python, I would. But as a full time dad with two kids I may have to postpone that. Thanks though.

Haha totally get it. But when working with dynamo. you will start to see its limitations. so you might need to supplement them with some custom nodes