Invalid set index '0' on base 'Array'

Godot Version

var dirs_count = open_dirs.size()

for i in dirs_count:
	for j in degrees:
		open_dirs[i] = [open_dirs[i][1] * -1, open_dirs[i][0]]


Getting the error code as if the array index I am assigning to does not exist. For context, I’m rotating an array of two coordinates (representing North/east/south/west) by 90 degrees. open_dirs[i] looks like this:

[0, -1]

and the full open_dirs variable could look like this:

[[0, -1]] # can have several directions, hence the for loop and nested list

This is the full error:
Invalid set index ‘0’ (on base: ‘Array’) with value of type ‘Array’

I didn’t figure out why this specific error was happening, but I just ended up making a new list to add the new directions to and then just replacing the old open_dirs.

have you tried to do this?

for i in dirs_count:
	for j in degrees:
		var new_dirs=open_dirs[i].duplicate(true)
		open_dirs[i] =[new_dirs[i][1]*-1,new_dirs[i][0]]