class Line():
def __init__(self, coor1 , coor2):
self.coor1 = coor1
self.coor2 = coor2
def distance(self):
for x1,y1 in self.coor1, x2,y2 in self.coor2:
distance = ((x2-x1)**2 + (y2-y1)**2)**0.5
return distance
coordinate1 = (3,2)
coordinate2 = (8,10)
li = Line(coordinate1,coordinate2)
li.distance()
Hi, I am not too sure why (x2,y2) wasn't able to be defined while the first variable (x1,y1) was. I am not too sure how to include both tuples in the for loop, but shouldn't both be defined or none of them are defined? Thanks!