Python 11/11 possible bug


#1


https://www.codecademy.com/courses/python-intermediate-en-egNXj/1/5?curriculum_id=4f89dab3d788890003000096
Python 11/11

Python prints: (1,2,3)
Error Pop-up says: "Oops. Try again, looks like you didn't print "(1,2,3)".


Honestly? For it to give me the green pop-up and let me into the next exercise.


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 str(my_point)


#2

We don't need to convert to a string. The representation does that for us.

    print my_point

#3

That's fine, I added it to the line just in case that was part of the issue, which it was not. But that is not the solution I'm looking for.


#4

Why not? It works, doesn't it? Passes for me.


#5

I don't think you copied that exactly, look closer at what it says it expects, and compare that to your output.


#6

Hi. I have this very same issue and below is 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(x=1,y=2,z=3)
print my_point

The output is (1,2,3) but I still can't move on because it says "Oops, you have not printed "(1,2,3)"

Can you help?


#7

Found it:

"(%d,%d,%d) % (self.x,self.y,self.z)" should have spaces in the %d:

"(%d, %d, %d)" instead of "(%d,%d,%d)"


#8

So the SCT was being a stickler for correct pattern match. The lesson here is to study the instructions closely for exact string format and content.


#9

Thanks, mtf. Thanks for your response.


#10

It takes me some time to find where the problem is, finally,your response helped me.Thank you very much.