# Python: what is the wrong in this code

#### Bamerni

Joined Jun 26, 2016
53
Hello everyone

I have the following code that calculate the distance between two points x(0,1) and y(0,1) but I don't get the answer

Python:
def distance(x, y):
dist = math.sqrt((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 )
return dist

print(distance((0,0),(1,1)))
Please can anyone help me correct this error?

#### upand_at_them

Joined May 15, 2010
766
What is the error? What do you get?

#### upand_at_them

Joined May 15, 2010
766
If that's your entire program you're missing the "import math" at the top. Aside from that I don't know what you're expecting that isn't working.

#### daGrizz

Joined Dec 22, 2020
1
Hello everyone

I have the following code that calculate the distance between two points x(0,1) and y(0,1) but I don't get the answer

Python:
def distance(x, y):
dist = math.sqrt((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 )
return dist

print(distance((0,0),(1,1)))
Please can anyone help me correct this error?