Building useful classes 11/11 - unsupported format error


#1

https://www.codecademy.com/courses/learn-python/lessons/classes/exercises/building-useful-classes?action=lesson_resume&link_content_target=interstitial_lesson

returns error:
Traceback (most recent call last):
File “python”, line 10, in
File “python”, line 7, in repr
ValueError: unsupported format character ‘)’ (0x29) at index 11

I expect (1, 2, 3) to print as a result of print my_point


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


#2

line 7, it seems the ) you use invalid. use a valid closing parenthis


#3

Hello, I’m struggling to understand. Do you mean the ) after self.z in line 7?


#4

well, look at the error message:

ValueError: unsupported format character ‘)’ (0x29) at index 11

the ) character you use at line 7 is invalid, type valid one, or copy this one: )


#5

Unfortunately copying and pasting that did not change the error message. I’m not understanding how my ) needs to be replaced with a different )


#6

what did you do? simplest solution, simply retype the entire line:

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

#7

Got it - I retyped the entire line and that fixed it. I’m still not sure how that ) was invalid… Thanks!


#8

not a valid ascii value it seems. Important thing is that the issue is resolved


#9