[Python] Calculating Euclidean Distance

Discussão em 'Python' iniciado por Stack, Agosto 6, 2025.

  1. Stack

    Stack Membro Participativo

    I have the code below to calculate Euclidean Distance. however, my function does basically nothing. It gives no output and not even an error, it just runs and finishes.

    lst_a=[1,2,3,4,5]
    lst_b=[1,2,4,5,8]

    def distance(lst_a, lst_b):
    sum_of = 0
    for x, y in zip(lst_a, lst_b):
    ans = (x - y)**2
    sum_of += ans
    return (sum_of)**(1/2)

    Continue reading...

Compartilhe esta Página