Week 2 Programming Assignment - Exercise 5 Assertion Error

I’m getting the following assertion error even though my code appears correct:

image

Here’s my code:

{moderator edit - solution code removed}

And with the three print statements included you can see my output appears correct:

Thanks in advance.

Note that it’s not complaining about the value: it’s complaining about the type, right? So what type is it? Have you tried:

print(f"type(db) = {type(db)}")

What does that show?

1 Like

Also note that it looks like you modified one of the lines in the template code:

db = np.squeeze(np.array(cost))

That’s not what that line originally looked like and there was no reason to modify it. If you’d like to get a clean copy of the notebook to see how it originally looked, there is a topic about that on the FAQ Thread.

1 Like

Thanks for replying so quickly. It was the line

db = np.squeeze(np.array(cost))

that was causing the problem. I would never have noticed that. I appreciate it!