I'm making a point class in python and I am encountering an error with my makeVectorTo method (a method that takes a second Point as input, and returns a new Vector that goes from starting Point to the second Point). When I try to print it, I am getting this error: AttributeError: 'tuple' object has no attribute 'h'.
How do I get rid of this and print it the way I want?
Here's my code:
class Point:
def __init__(self, x, y):
self.x = float(x)
self.y = float(y)
def makeVectorTo(self, coor):
dx = abs(self.x - coor.x)
dy = abs(self.y - coor.y)
newCoor = (dx, dy)
return newCoor
###Testing Point Class###
vec1 = point1.makeVectorTo(point2)
print(vec1.h, vec1.v, "should be 0,3")
The error looked like this:
Traceback (most recent call last):
File "main.py", line 30, in <module>
print(vec1.h, vec1.v, "should be 0,3")
AttributeError: 'tuple' object has no attribute 'h'