Veneer Project

Link to page: https://www.codecademy.com/paths/computer-science/tracks/cspath-cumulative-art-marketplace/modules/cspath-veneer/projects/veneer

I am getting an error that i cannot find the cause of. It’s highly frustrating. Can someone spot it?

I also noticed in the video (https://www.youtube.com/watch?v=c4s0C52sqjQ) at 7m02s that this male who is providing the answer was sneaky and changed an error he made without informing the viewer. I’m worried that he has done something similar later in the video and i haven’t been able to spot it. Shame on him for this. It’s so annoying how difficult you make it for the student. This stuff is complex and you need to stop these antics.

Additionally, Codecademy should provide us with the finished code so we can check it against ours at the end. After I finish this track I’m going to check other coding teaching websites. Very disappointed of late with Codecademy.

My code:
class Art:
def init(self, artist, title, medium, year, owner):
self.artist = artist
self.title = title
self.medium = medium
self.year = year
self.owner = owner

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

class Marketplace:
def init(self):
self.listings =

def add_listing(self, new_listing):
    return self.listings.append(new_listing)

def remove_listing(self, expired_listing):
    return self.listings.remove(expired_listing)

def show_listings(self):
    for listing in self.listings:
        print(listing)

class Client:
def init(self, name, location, is_museum):
self.name = name
self.is_museum = is_museum
if is_museum:
self.location = location
else:
self.location = “Private Collection”

def sell_artwork(self, artwork, price):
    if artwork.owner == self:
        new_listing = Listing(artwork, price, self)
        veneer.add_listing(new_listing)

def buy_artwork(self, artwork):
    if artwork.owner != self:
        art_listing = None
        for listing in veneer.listings:
            if listing.art == artwork:
                art_listing = listing
                break
            if art_listing != None:
                art_listing.art.owner = self
                veneer.remove_listing(art_listing)

class Listing:
def init(self, art, price, seller):
self.art = art
self.price = price
self.seller = seller

def __repr__(self):
    print("%s, %s" % (self.art.title, self.price))

veneer = Marketplace()

edytta = Client(“Edytta Halpirt”, None, False)

moma = Client(“The MOMA”, “New York”, True)

girl_with_mandolin = Art(“Picasso, Pablo”, “Girl with a Mandolin (Fanny Tellier)”, “oil on canvas”, 1910, edytta)

print(girl_with_mandolin)

edytta.sell_artwork(girl_with_mandolin, “$6M (USD)”)

veneer.show_listings()

moma.buy_artwork(girl_with_mandolin)

print(girl_with_mandolin)

veneer.show_listings()

Console is printing:
Picasso, Pablo. Girl with a Mandolin (Fanny Tellier). oil on canvas, 1910. Edytta Halpirt, Private Collection.
Girl with a Mandolin (Fanny Tellier), $6M (USD)
Traceback (most recent call last):
File “script.py”, line 77, in
veneer.show_listings()
File “script.py”, line 26, in show_listings
print(listing)
TypeError: str returned non-string (type NoneType)

You didn’t ever add listings to your marketplace before trying to print them.
That’s just one quick observation.

Here’s a quick lesson for you
Coding is going to be hard and frustrating. There isn’t alway’s a “Fill in the answer” You can’t expect to just look at other people’s code to solve your problems forever. It doesn’t work with art, it doesn’t work with math, it doesn’t work in programming.
There are a seemingly infinite amount of resources out there to learn programming. You should check them all out. The point is - it takes time to absorb and understand everything.
If you are getting frustrated by a problem it helps to step away from it and come back later.

Also READ THE ERROR MESSAGES. While they can be vague, this one literally spells out the error for you. It told you there was a problem with your veneers show listing method - the problem was it expected a string and got nothing.

hey man, thanks for taking the time to respond. I agree with you about coding taking time. However I followed the response video for this project second by second – twice – and still could not find why my code provided an error message while the response’s did not. I think that is inexcusable and is making the learning process unnecessarily difficult.
Yes, I know that there was an error message regarding a string method, but my code is identical to the response video’s. This is the frustrating part. A copy of the code should be made available for this project. I shouldn’t have to spend an hour literally transcribing the code from the code academy youtube video response. To catch a sneaky video edit being made, without informing the viewer, is shameful. As a teacher in another field, this is inexcusable behaviour. It ruins the momentum and motivation for the student.
If I wanted to use the infinite amount of videos available, I would do so, and cancel my code academy fees. But we’re paying for a product here and I think feedback should be useful to the management of this site.
I’ve already stepped away, and come back to this project on now my third day. This is why I reached out with my message yesterday.

Hi @flexidex

We would like to help find the problem, but the code that you posted is only partially formatted, therefore we cannot see some of the indentation. This makes it difficult for other users to help.

See How to ask good questions (and get good answers) for information on formatting code.

The error message suggests that a __str__ method returned a non-string (type NoneType). Note that in your posting of that message, the double-undescores in the name of that method are not visible, and that instead we have str in bold type. This is also due to its not having been formatted for the posting.

Like a __str__ method, a __repr__ method is useful for supplying a means for an instance of a class to be represented as a str. Among other things, this enables the object to be represented for display by a print statement. Your __repr__ method for class Listing does not specify a return value, so that defaults to None

  def __repr__(self):
    print("%s, %s" % (self.art.title, self.price))

That creates a problem when you try to print a Listing. Instead of using print in that method here …

    print("%s, %s" % (self.art.title, self.price))

… you should return the value.

1 Like