List items insert in items of a nested List


#1

Hello,

I have a problem with some lists. I have two lists, one is a nested list. I want to insert the first item of the “normal” list (right side screenshot), in the first item(list) of the nested list (under the phyton code). Second item in the second nested list and so on.

I don’t want to do it manually, so I trying to solve it with Python but Dynamo don’t like my code :frowning:

Error: unsubscriptable object

Sorry for the bad python code. I think the problem is, that I try to access the Input directly.

listp

 

 


#2

OK. I have one solution without Python:

  • I [flatten] the nested list and
  • [take Every2 item].
  • From the flatten list I [Drop Every 2 Item]. Now I have the nested List deconstruct in two lists.
  • [Create List] with 3 indicies and put the lists in order.
  • [List Transpose] construct the right list.
 

I keep the topic as “not resolved”, until someone can explain to me, why the python code not work.

Thanks


#3

insert is a function and should use (), not [].

:slight_smile:


Python Nodes Basics
#4

Oh man … XD Thank you. This was the mistake.

shame It’s late in europe…

 


#5

Hi Leo,

Have you had a chance to try out one of the list combining nodes? That will remove the need for any python code.

2015-04-17_11-47-55


#6

Hello Dimitar,

thanks for your solution. It is working fine, for the case to insert the item in top of the List or in bottom (AddItemToEnd/AddItemToFront Node)

My problem is, I want the item between the first and the last item: [[1,a,2],[1,b,2],[1,c,2]…]


#7

Same workflow just change the function:

2015-04-17_17-57-32


#8

Thank you Dimitar :slight_smile:

I had the same thought but I had used the List.Combine Node (that’s why it did not work) ^^ For me it looks, they doing pretty similar things. Can you explain what is the diffirent between List.Combine and List.laceShortest?

 


#9

Leo you’re right, they’re quite similar. I already tried to explain their functionality in the second to last post in the following thread: http://dynamobim.com/forums/topic/wheelbase-points/


#10

Many thanks for your effort Dimitar! :slight_smile: