Can I extract sublists through variables?

Hi all

I want to automatically extract the sublist according to the variable value.
However, although it is the same equation, there is a difference between when a constant(integer) is added and when a variable is added.
I wonder why they are different. Is it possible to get same result when I put in variables, like when I extracted sublists as constant numbers

Your list levels are going to be screwed up. The sequences you use in the second block use the same variable but are not the same sequence (in that they are three unique instances of the same values but not the same list used three times). So the code block doesn’t execute with n=0 for all instances and then n=1 for all instances. It’s the same as giving all indices a list to iterate through which is likely going to cause Dynamo to auto-interpret the list comprehension and give you different results.

1 Like

Thank you for your detailed explanation.

Then, is there any way I can solve this?
Is it better to use Python code to extract same result when I put in variables, like when I extracted sublists as constant numbers?

I should have added that the list[i][i] notation is a shorthand and doesn’t have access to the normal DesignScript node features like list levels so you have no additional control over what Dynamo is doing.

The trick would be to use the the actual GetItemAtIndex node and utilize proper list levels.