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)