1
I have a code that calculates the Euclidean distance between two points.
However, when executed it presents the error: "Typeerror: list indices must be integers, not tuple"
I don’t 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)
Thanks in advance.
You at least tried to understand the code of the other question before changing it?
– Woss