Python, Every nth element in list

Hi all,

Need some help with this list structure & python. I’ve been able to put together a python node that will grab every nth element within a list. It works great when the list is flattened, however, the data i have has been grouped by level and i want to keep it that way. The goal is to grab the nth item of every level that the element is placed on. Still new to python so im not sure what syntax i should be using to achieve this. I can see that currently, it is grabbing every nth group of elements rather than the element in the group.


Like this?

1 Like

If your list structure is going to be inconsistent it’s easiest to wrap your python code in a custom node and use list levels.


I was wondering about that. Can you show how please?

Read through the Primer on Custom Nodes. It explains everything.

Thank you, that was basically it, just needed to change line 10 to be item[::n], should of been clearer in saying i was looking for every nth item. Thanks again!