Please helps to explain List.TakeEveryNthItem

I am a beginner of Dynamo, and wondering how the List.TakeEveryNthItem works. I have read the dictionary and searched the google and still don’t get how the offset work.

When I got a list

n=3, offset=5,

I saw some forums said, it offset the list by the remainder (which I don’t know remainder means subtract or divide)

Because I am not sure how it works, so I list out all the “possible lists” after offset:
and the respective outputs are:
But it turns out the output is 2,5,8

Please helps to explain how this block works.
Really Thanks~

The dictionary says: “Take Every Nth Item will produce a new list keeping items from the input list at intervals of the input ‘n’ value. The starting point of the interval can be changed with the ‘offset’ input. For example, putting 3 into ‘n’ and leaving the ‘offset’ as the default of zero will keep items with indices 2, 5, 8, etc. Changing the offset to 1 would instead keep items with indices 0, 3, 6, etc. Notice that the offset ‘wraps’ through the entire list. To remove selected items instead of keeping them, see ‘DropEveryNthItem’. In the example below, we first generate a list of numbers using Range, and then keep every other number by using 2 as the input for ‘n’.”

The wrap means after it finishes through the list, it will go back again until it reaches the offset. So your offset is 5, so the first item it takes is after 5 (index 4, value 5). With an interval of 3, the next is 8, but the list ends there so it goes back from the start. from 8, count 3 intervals, 9, 1, 2. So the next value is 2.

The list reorders itself to the original order, so instead of 5,8,2 it is 2, 5, 8.

Dear Kenny,

With this logic, it works find with n=3, offset=5.
The new list should be,

But when I change to n=2, offset=5,
the list is the same
5,6,7,8,9 , 1,2,3,4
the output should be 7,9,2,4,6 and rearrange to 2,4,6,7,9.

But the real output is 1,3,5,7,9.:tired_face::tired_face::tired_face:

Thank you

1 Like

That’s true. It probably depends on their wrapping logic. If it was really wrapping, with n = 2 and offset = 5, it should be:

5, 6, 7, 8, 9, 1, 2, 3, 4

with a list of: 2, 4, 5, 7, 9.

They probably have the logic as counting forwards and backwards from the offset, which would produce the 1, 3, 5, 7, 9 list. Try it out with more combinations and let me know how it goes.

Dear kenny,

I guess I will do more google on this function. And no matter how I arrange the list, 1 and 9 are consecutive, they can’t be counted on the same output when n is even number. (but the real output have both 1 and 9)
Or there maybe other logic of this block.

I think you guys basically have it now. EveryNth represents an infinite series, but it doesn’t actually wrap. The offset just sets where the Nth count falls (not where it starts).

1 Like

It is a shame to say that, but I can’t find out a pattern to fit this function and gave up already…

What are you trying to use this for? Or rather what outcome do you want?

I don’t use it for anything, I am learning the Dynamo and just try to understand its logic.
And since I can’t solve it, so I just let it go and study next item :slight_smile:

Maybe this will help.

Every Nth Item represents an infinite set (of every Nth item) taken from a specified list of a specified length. There is no wrapping of the list because the sequence continues on in both directions. Offset merely establishes where those Nth counts fall. A 0 offset would start counting at the first item, an offset of 1 would start at the second item, and so on. Only items in the input list are returned but the set would actually contain every Nth item in an infinite series.


no guessing required:


Really thx!
If did not get it wrong, basically we need to think about to complete the pattern.