W2_Ex-8_AssertionError: Wrong length for d[‘costs’]. 20 != 1

If your costs array has 20 elements, it means you did not call optimize correctly: you did not pass through the actual value of the number of iterations that the test case requests. You hard-coded the number of iterations to be 2000, which is a mistake.

I am adding this reply because I just edited the post from SkyWalker to remove the solution code provided there. We are not supposed to share solutions in a public way. Sorry that I had not noticed this thread before.

This issue has come up many times. Here’s another thread about it which has the above explanation in a bit more detail.

3 Likes