List - Get item a index using sequence?

revit
python

#1

Hi,

I’m trying to group my data it sets of n, so for example if N was 2, then I would like index (0,1),(2,3),(4,5) together. See screenshot below for example.

Any help would be appreciated.

I would also be interested in a solution using python as I’m trying to get into that.

Thanks

Joe


#2


I think List.Chop will do the job for you.


#3

#4

Wow thank you, I completely forgot about that node.

Thanks!


#5

You’re welcome!


#6


You could theoretically do it without List.Chop (I wanted to find out if I could).


#7


#8

That’s the same function still, just in a code block.


#9

I was trying to find a way to do it like that, however the only sequence I knew was x…y…z, didnt know how to make it non-linear.

Thanks!


#10

It can be a pretty useful tool to create lists, it means you can use lists as inputs to so that might be handy.


#11

These can be quite useful :slight_smile:
image


#12

…and that’s new to me as well.
Always something new to learn.