I am trying to create a 2d array consisting of various attributes from an object, then sorting the array to find a specific min and its related values. I keep getting the error: list assignment index out of range
Here is some sample code:
if cool_stuff[c].coolest_stuff = 0:
a_list = []
b_list = []
c_list = []
d_list = []
a_list.extend([cool_stuff[c].a_1,cool_stuff[c].a_2,cool_stuff.a_3,cool_stuff.a_4])
b_list.extend([cool_stuff[c].b_1,cool_stuff[c].b_2,cool_stuff[c].b_3,cool_stuff.b_4)
and so forth. Just assume proper indents.
Next is
col = int(len(d_list))
silly_array = [[0] * col for j in range(4)]
for d in range(len(d_list)):
silly_array[0][d] = int(a_list[d])
Here is some sample code:
while c < len(cool_stuff):
if cool_stuff[c].coolest_stuff = 0:
a_list = []
b_list = []
c_list = []
d_list = []
a_list.extend([cool_stuff[c].a_1,cool_stuff[c].a_2,cool_stuff.a_3,cool_stuff.a_4])
b_list.extend([cool_stuff[c].b_1,cool_stuff[c].b_2,cool_stuff[c].b_3,cool_stuff.b_4)
and so forth. Just assume proper indents.
Next is
col = int(len(d_list))
silly_array = [[0] * col for j in range(4)]
for d in range(len(d_list)):
silly_array[0][d] = int(a_list[d])
I keep getting an error message doing this. What is the problem.
Last edited: