I have a vector called POSITION, with the following values:
- position = [40.51, 30.52, 30.31]
I have a vector called COORDINATES, with the following values:
- coordinates = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]
Each index of the POSITION vector corresponds to another 4 of the coordinate vector. For example:
- position = 40.51 , 30.52, 30.31]
corresponds to:
- coordinates = [ 10, 20, 30, 40 , 50, 60, 70, 80, 90, 100, 110, 120]
I have the script below that, when detecting a value above 40.00 in the POSITION vector, assigns random values to the corresponding 4 positions in the COORDINATED array.
import random
posicao = [40.51, 30.52, 30.31]
coordenadas = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]
for indice in range(0, len(posicao)):
if posicao[indice]>40:
for indice2 in range(indice*4, indice*4+4):
coordenadas[indice2] = random.randrange(0,200) #gerar os aleatorios entre 0 e 200
print(coordenadas)
However, I wish instead of modifying the 4 values, just modify the last 2, for example:
- position = 40.51 , 30.52, 30.31]
Modify only:
- coordinates = [10, 20, 30, 40 , 50, 60, 70, 80, 90, 100, 110, 120]
How do I change this code to achieve this?
I am grateful to those who can help me. I think it's something easy, but I can not see the solution.