Veneer exercise - TypeError

Hi everyone,

kinda stuck on this veneer project on a TypeError that I cant seem to figure out, this is the error:

Traceback (most recent call last):
File “”, line 68, in
File “”, line 24, in show_listings
File “”, line 50, in repr
return ‘$s, $s’ %(, self.price)
TypeError: not all arguments converted during string formatting

I think the error is somewhere between the Listing repr function and the moment I call veneer.show_listings(). I’ve checked the tutorial video a few times but cant seem to figure it out. I know my Art class is working properly and I know my Client objects are also behaving as they should.

Any help would be appreciated!

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.location)
class Marketplace():
  def __init__(self):
    self.listings = []
  def add_listing(self, new_listing):
  def remove_listing(self, expired_listing):
  def show_listings(self):
    for listing in self.listings:
class Client():
  def __init__(self, name, location, is_museum): = name
    self.is_museum = is_museum #True or False
    if is_museum:
      self.location = location
      self.location = "Private Collection"
  def __repr__(self):
    return '%s. %s.' %(, self.location)
  def sell_artwork(self, artwork, price):
    if artwork.owner == self:
      new_listing = Listing(artwork, price, self)
class Listing():
  def __init__(self, art, price, seller): = art
    self.price = price
    self.seller = seller
  def __repr__(self):
    return '$s, $s' %(, 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)", 1910, "oil on canvas", edytta)

edytta.sell_artwork(girl_with_mandolin, "$6M (USD)")



Your error message describes the problem and says where it is happening

yeah, I realized that… the issue is I don’t understand why. I think my repr function is correct…and as far as I can tell while I trace back the code everything seems to work.

So why isnt the .art.title or .price arguments being converted to string format? This seems to be the issue since when I call the sell_artwork method it isnt able to populate the listings list.

You could make smaller program that does the same thing:

print('$s, $s' % ('blah', 3.50))

That would give you less to look at.

What action is being carried out there?
Can you make that action happen in any other context, what’s the minimal way you’d do it, how would a tutorial present that to you?
What if you copied the tutorial code for that action, would that that have the same problem? Could you turn tutorial code for string interpolation into a version that interpolates a string and a number into a string template?

there’s nothing particularly difficult involved, just isolate and study the situation and compare to references and/or what you meant should happen

… so don’t leave it at that. that’s avoiding looking at it.

1 Like

dear lord.

Its late, im stupid, and I was using $ instead of %. Jesus Christ.

Thanks for your help and saintly patience!

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.