TYPE ERROR in Week 2 practice lab

My program is showing an error in line 7. Please guide.

TypeError Traceback (most recent call last)
5 cost = compute_cost(x_train, y_train, initial_w, initial_b)
6 print(type(cost))
----> 7 print(f’cost at initial w: {cost:.3f}')
9 # Public tests

TypeError: unsupported format string passed to numpy.ndarray.format

1 Like

Are you using the Coursera Labs environment, or are you using some other platform?

Coursera lab environment

Perhaps your compute_cost() function is not returning a floating point scalar value.

Hi, I am getting the same error. How do I change that? Can I show you my code by private message to see where the bug is?

you can check the hint which is there and then try to fix your code. And yes, if you want feel free to share your code.