I have a code that calculates the Euclidean distance between two points.
However, when I execute it it presents the error: "TypeError: list indices must be integers, not tuple"
I do not know what I'm doing wrong.
Below the code:
import math
AP_X = [1,2]
AP_Y = [1,2]
demanda_X = [1,2]
demanda_Y = [1,2]
ap = list(zip(AP_X, AP_Y))
demanda = list(zip(demanda_X, demanda_Y))
distancia = []
for i in ap:
for j in demanda:
distancia.append((math.sqrt(pow(demanda_X[j] - AP_X[i], 2) + pow(demanda_Y[j] - AP_Y[i], 2))))
print (distancia)
Thank you in advance.