Python class Point.draw() not working

I’m getting this error: AttributeError: ‘NoneType’ object has no attribute ‘draw’

Can anyone explain why I am seeing this error? Thanks.

My code is below:
class Point:

def __init__(self, x, y):

    self.x = x

    self.y = y


def defaults(cls):

    cls(1, 2)

def draw(self):

    print(f"Point ({self.x}, {self.y})")

robert = Point.defaults()


fix your code you have forgot to use return keyword

def defaults(cls):
return cls(1, 2)

1 Like