Add items in front of sublists

Hi

I got this list of items:

And I want to add two entries of 0 at the first 2 indexes of the sublists… But at the best I can only add one 0 at the front. What am I missing?

Captura de tela 2022-07-20 113501

1 Like

I kinda got it.

Although the result is what I want, feels odd. Is there a better way of getting the same result?

I don’t think there is a better method. Maybe only replacing the List.Flatten node with a List.Normalize node with a 2 as other input.

2 Likes

A Single Python node alternative :snake:

The ‘c’ variable ensures that the correct index is used, as using ‘list.index(element)’ will return the first index of an element on the list, making it tricky to deal with duplicates.

3 Likes

The reason it doesn’t work is that you want to add two items to a list. You’re presenting Dynamo with the item [0,0], which, no matter how you use this node, will always be added as just one item.
What you actually want to do is find a way to join two lists.
You can theoretically just use List.Join but I find it doesn’t work that well when it comes to different list levels, but luckily there’s still List.Map:


But I have to say the best solution is probably what @Ewan_Opie suggests and dive into Python.

2 Likes

Really elegant solutions. Thanks @Ewan_Opie and @PauLtus.

1 Like