Art Markeplace Project, .buy_artwork method

I am almost finishing with the Art Market Place Project, and I quite don’t understand something:

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

I don’t really understand why art_listing = None and art_listing != None and what that means.

p.s. even after watching the walkthrough, I still don’t understand

Hello, @jooaugusto8418467006, and welcome to the Codecademy Forums!

This is the technique we have chosen to indicate that prior to the for loop, the work of art has not yet been located among the listings:

      art_listing = None

This is a test to determine whether is was found among the listings during execution of the for loop:

      if art_listing != None:

If that condition evaluates to True, the work of art was found among the listings, indicating that it had indeed been offered for sale, and we can proceed with the transfer of ownership, and remove it from the listings.

Check the spelling here:

      for listing in venner.listings:

Ok, now I got it, thank you sir :smiley:

1 Like