Can't get the last part of Veneer to work

So I’m almost done with the Veneer project and I peeked into the solution a few times for assistance. I’m getting the hang of classes and such, but there’s something unusual.

so when a piece of artwork is changing hands, but for some reason the method just isn’t working and the girl_with_mandolin is still staying with edytta. I don’t know why. I am not getting an error message or anything. Any help?

1 Like

Hi @salimfarhat,

Check this if block in the buy_artwork method of Client:

        if art_listing != None:
          art_listing.owner.art = self
          veneer.remove_listing(art_listing)

Due to its degree of indentation, it is currently part of the for loop. Is that as it should be?

Also consider whether the components of this statement are in the correct order:

          art_listing.owner.art = self

Link to project: Veneer

1 Like

I figured it had something to do with that. But I cannot for the life of me find out what is.

The for loop in the buy_artwork method looks within the listings for the desired piece of art. If it is found, the break is executed, and no more code within the loop is executed. In order for the if block mentioned above to be executed, it must lie outside the for loop. Remove one level of indentation from that if block in order to remove the block from the loop.

In this statement, the components are not in the correct order:

          art_listing.owner.art = self

The listings contain works of art, and the works of art have owners. That should be reflected in the code as follows:

        art_listing.art.owner = self

Note that in the corrected code, a level of indentation has been removed.

1 Like

Sorry for the delay, but I was wroking on the pokemon project and I had difficulties

removing the indentation and changing the word order did nothing. I even outright removed the art_listing.art.owner = self (or .owner.art) and it did nothing at all.

Edit: I really don’t understand what is going on. You’re giving good information and I went on to straight up rewrite the code exactly as shown in the solution.

I noticed that the ! in != is not grey. Is that contributing to the error?

Hi @salimfarhat,

The only problems with your original code were in the buy_artwork method of the Client class. So that we can take a close look at the changes you have made, could you please post that method in its current form?