Veneer Project - Loose Variable Question

Veneer Project Link:

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

My code link:

I have a small question on this project. In step 29-31 (line 53 in the linked veneer.py file), the instructions call for the appropriate listing to be saved as art_listing. When I did this initially and passed art_listing into the veneer.remove_listing() call in the buy_artwork method, it gave me a Value Error: list.remove(x): x not in list error.

However, when I changed the argument to just listing, the project functioned as it was supposed to. I even added more art and different clients to test and it appears to be functioning correctly.

This leaves me with a loose variable at line 57. I’m not sure why Python is kicking out that Value Error or why x is not in the list, when they appear to be referencing the same art instance.

@blog4247097350,

The instructions say to save the listing as art_listing. In your code, you saved the artwork passed into the buy_artwork method as art_listing. Take a look at the video at the top of the exercise if you want to see how Matt does it.

2 Likes

Okay, thank you. I’m actually in the process of watching it now. I wanted to see if I could chase that down before seeing the professional solution.

In that video, there was something I noticed. In the Art class the developer’s code is as follows:

class Art:
  
  def __init__(self, artist, title, medium, year):
    self.artist = artist
    self.title = title
    self.medium = medium
    self.year = year
    self.owner = owner
    
  def __repr__(self):
    return “%s. “%s.” %s, %s.” % (self.artist, self.title, self.medium, self.year)

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

print(girl_with_mandolin)

This returns:

Picasso, Pablo. "Girl with a Mandolin (Fanny Tellier)". 1910, oil on canvas.

In the Art instance, the medium and year arguments are reversed. How is it that the __repr__ method is placing the year before the medium, when the the __init__ method calls for the medium argument before the year?

2 Likes

I’ve not seen this video before but that looks like a small error. It’s sort of corrected because the arguments medium and year are then reversed when creating the instance-

Art("Picasso, Pablo", "Girl with a Mandolin (Fanny Tellier)", 1910, "oil on canvas")
Art(artist="artist", title="title", medium=year, year=medium)
1 Like

It looks like he passed his parameters to the Art class in the wrong order on accident.
so 1910 got saved asself.medium and “oil on canvas” got saved as self.year

2 Likes

Ah, okay, I see what happened here. Thank you.