GhPython indexing through input branch

I am trying to index through a branch of points using GhPython Script. I am trying to take these points and be able to iterate through them kinda like the list item command works but within the GhPython Script so i can use this logic to do other operations. Below are things that i have tried so far.

in the first image i just draw a random curve and divide it 4 times. Then take the point data into the GhPython Script and then print the variable x. This works no problem and prints all the points in the Output.

In the second image I do the same as the first but instead try to extract one point by treating x as a list in python and it gives me error messages. I’m not sure if I just have a syntax error or if you have to treat these branches different then a list. I’m unsure what the issue is.

Right-click the x input and set it to “List Access”.

Thanks I was trying to use the “Tree Access” one that is listed under the “List Access” now and it is saying it takes 2 arguments and 1 is given. below is a picture of whats going on. I’m trying to do a similar thing with the indexing through the values in a list but want to be able to do it to trees as well. My syntax is probably wrong.

Since it’s a DataTree, you’ll have to access it with x.Branch(branch_index)[item_index_in_branch]
See more here

If you want to handle trees as nested lists you can also use ghPython’s inbuilt helper functions.

import ghpythonlib.treehelpers as ght

list_x = ght.tree_to_list(x)
print list_x[0][0]