So for a task I need to be able to reflect the y-value of a tuple. This is what I have so far, but I keep getting this error: 'NoneType' object has no attribute 'print'
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def print(self):
print((self.x, self.y))
def reflect_x(self):
if self.y < 0:
print((self.x, abs(self.y)))
if self.y > 0:
print((self.x, -abs(self.y)))
if __name__ == "__main__":
p1 = Point(1,4)
p1.reflect_x().print()
p2 = Point(-3,5)
p2.reflect_x().print()
p3 = Point(-3,-5)
p3.reflect_x().print()
These are the values I should be getting:
(1, -4)
(-3, -5)
(-3, 5)
The bottom part (in if __name__ == "__main__":
) is a test code which I'm not allowed to change, so the main problems should be lying in the top part, so basically inside the Point-class.