Building Useful Classes - too many arguments?


Traceback (most recent call last):
File "python", line 10, in
TypeError: Point3D() takes exactly 1 argument (3 given)

Not sure why my Point3D class is only accepting 1 argument when I've defined 3 in addition to "self". Plus my code looks like everyone elses....

def Point3D(object):
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z
    def __repr__():
        return "(%d, %d, %d)" % (self.x, self.y, self.z)
my_point = Point3D(1,2,3)

print my_point


Hi @ashleyz413,

Here, you should be defining a class rather than a function ...

def Point3D(object):

It should be ...

class Point3D(object):

In this method header, you need to include a self parameter within the parentheses ...

    def __repr__():


Thank you, think I was just staring at it too long......