So, I've got a line of buttons, and I've got an array where each button is assigned to an index of that array, like

array[1] =$Button1
array[2] =$Button2
array[3] =$Button3
array[4] =$Button4

and I've got a for loop like this,

for index in range(1, 4)
	if array[index].is_pressed() == true:
		array[index].set_pressed(false)
		if not index-1 < 1:
			array[index-1].set_pressed(true)

and this works to move the pressed button down one, but if I try almost the exact same thing,

for index in range(1, 4)
	if array[index].is_pressed() == true:
		array[index].set_pressed(false)
		if not index+1 > 4:
			array[index+1].set_pressed(true)

it just does not work. It unpresses the button on array[index], but does not press the button on array[index+1]

Am I missing something or doing something wrong? I'm not exactly a professional so my first assumption is that I have to be missing something stupid.

Did all the indenting get removed? That's a bother.

    wormclaw Did all the indenting get removed? That's a bother.

    It seems that in order to place the code you need to highlight it at the top and bottom ~~~

      K nevermind I guess I just wasn't taking into consideration how the for loop works. Obviously if I'm going up a range of numbers and turning each one off in sequence if it's on, then if I turn one on that's one more than the current iteration in that sequence then it's just going to get turned back off in the next iteration.

      So I found out that the for loop can work backwards. May as well mention it here since I bothered to post this. I got it to work like this,

      for index in range(4,0, -1):
      	if array[index].is_pressed() == true:
      		array[index].set_pressed(false)
      		if not index+1 > 4:
      			array[index+1].set_pressed(true)