W2_Ex-8_Wrong values for d['costs']

Hi. All tests passed. Except for Ex 8.

{moderator edit - solution code removed}

AssertionError : Wrong values for d[‘costs’]. [array(0.15900538)] != [array(0.69314718)]

@paulinpaloalto

1 Like

Is it just me, or do you never assign a value to the variable costs that is returned in d ?

1 Like

Thank you. I mis-spelled costs when returning from optimize. Have a good day.

2 Likes

Sharp eyes are always a good thing in programming. I definitely know the feeling of staring at a piece of code and having trouble really “seeing” it. :nerd_face:

Just for future reference, please note that we aren’t supposed to post solution code publicly. No real harm done in this case, since I have edited to post to remove the code. Generally we can help you just from the error message or the exception trace. Those will sometimes reveal a bit of the source code, but the point is no-one can just “copy/paste” a solution from that. Of course the help we will be able to give you will probably not be as “on point” as that which ai_curious was able to provide without seeing the source code. :laughing:

In the cases in which we can’t figure out how to help without seeing the code, there are non-public ways to get direct help with your source code.

2 Likes

@salah.elfarissi is probably too young, but in my lifetime there were people who advocated a practice called pair programming for exactly this reason. One would type, the other would watch. And presumably say “Yo, that needs to be costs, plural, not cost, singular”. I only worked on one project that fully embraced it for new code. And one that used it to do code inspections on existing code; one the author and one who had never seen it before. I do think it is hard to find this kind of bug in this kind of programming language where you don’t have to explicitly type your variables and silently allows global scope.

@paulinpaloalto I figured I’d let you be the no source code ‘bad cop’ here since I don’t carry the Übermentor designation. Cheers

3 Likes

I was having the exact same issue and spent hours searching! Thank you @ai_curious !!

2 Likes

I had exactly the same problem. Thanks to this post after having spent much time debugging it.

2 Likes