Computer Science-Classes-Veneer


I have been working on the project Veneer and have come over a problem. When writing the code for string representation in the Art Class I attempted to write

def __repr__(self):
    return '%s. %s. %s. %s. %s %s.' (self.artist,self.year, self.medium, self.year,, self.owner.location)

The second dot in and self.owner.location are not becoming white like they are in the tutorial when I went to see what was wrong. Also, maybe I forgot something obvious I learned but what are those dots called. If someone could help me understand why they are not and how to do it correctly that would be amazing. I thank you for your help I am not very good at this yet but I enjoy the course and community.

Remember to insert the modulo operator.

Welcome to the forums!

The way you’ve used string formatting is incorrect; that’s why the linting isn’t working as expected (though the code editor on Codecademy’s site sometimes doesn’t highlight things properly for no apparent reason).

As @mtf just mentioned, you need the modulo operator if you’re formatting your string this way. However, you can also use .format() or f-strings.

1 Like

Unfortunately that is not always the case. Many of the course modules date back to before version 3.x (5?) when that formatting was introduced. `f-strings don’t work in a great many exercises. Be sure the version supports it.

1 Like

Oh, wasn’t aware of that. Nice to know.

1 Like