Spaces:
Runtime error
Runtime error
File size: 475 Bytes
4258877 e0d7f28 4258877 e0d7f28 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import math
def euclidean_distance(list1, list2):
"""
Computes the Euclidean distance between two lists of numbers.
:param list1: The first list of numbers.
:param list2: The second list of numbers.
:return: The Euclidean distance as a float.
"""
if len(list1) != len(list2):
raise ValueError("Both lists must be of the same length")
squared_diff = sum((a - b) ** 2 for a, b in zip(list1, list2))
return math.sqrt(squared_diff)
|