A very simple list operation in GH python but failed with error "index out of range:". I really don't know why

Hi Everyone,

As you see, I imported a list as x for GH python and create variable a, then I defined an empty list variable b, then I want to give the value of a[0] to b[0], but it shows the error “index out of range: 0”. What’s the problem of it? I don’t think I will meet the problem in ordinary python environment.

Thanks for any suggestion and help.

list_test.gh (6.4 KB)

b = [] creates an empty list
b[0] = ... tries to set the first item (which is not exist) of the list, You need to change it to b.append(a[0]).


Thank you so much Mahdiyar!!