[SOLVED] 11/11 problem


Edit: I solved this. Check the bottom of the post.

I have gotten stuck in the exercise called 'Building useful classes' in the 'Classes' lesson, here.

Error message:

Traceback (most recent call last):
  File "python", line 11, in <module>
  File "python", line 7, in __repr__
TypeError: not all arguments converted during string formatting

I don't know what's wrong with the code, it looks like correct. I have tried writing it differently, but it has net been working.

My code:

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)


I just rewrote the code as it was and it worked.


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