Building useful classes


#1

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

Error:
. It looks like you didn't print "(1, 2, 3)".

I am unable to understand my mistake. Can someone guide me on this?


#2

here:

return "(%d,%d,%d)"%(self.x,self.y,self.z)

the string returned should be an exact match, you miss a few spaces


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.