I have a class Coordinate, which holds 2 integer values, x and y.
I have a method to compare 2 Coordinates to see if they are equal, but I get a NameError when I attempt to define the parameter of this function as a Coordinate.
Here is my code:
def equals(self, other:Coordinate):
try:
return (self.x==other.getX()) and (self.y==other.getY())
except AttributeError:
return False
However, when I run the class file, I get the error
NameError: name 'Coordinate' is not defined
for the first line.
The program works when I remove ":Coordinate" from the parameter but I would like to know if there is a way for it to work while still keeping it there.