Week 2 code assignment error

While doing the code assignment for the compute cost part, I tried to run the code and this came out. Can anyone help me with this? Thanks in advance

Hi @Elise_Poniman,

The error indicates that the cost variable that your compute_cost function produces is an array, which should have been a float type instead. You may start debugging from here.


The variable cost that you calculated outputs an array, but it should be a scalar.
The string formatting part (the .3f) in the print statement requires a scalar. That’s why it yields the TypeError. Please check the output of your function compute_cost.

1 Like

Hi @Elise_Poniman , I am closing this thread, please open a new one if you have any follow-up.