C3_W1_KMeans_Assignment.ipynb#Exercise-1 'find_closest_centroids' is not defined

I get the following error after submitting the completed assignment (KMean, W1). As shown as the following.

{mentor edit: image of code removed}

I really don’t know why ‘find_closest_centroids’ is not defined.
Plz help.
Thanks a lot!
Best wishes.

A couple of thoughts:

You’ve posed in the “AI Discussions” area. Instead you should post in the forum area for the course you are attending.

You can move your thread using the “pencil” icon in the thread title. Select a course and topic, then add a tag for the week number.

Second, please do not share your code on the forum. That’s not allowed by the course Code of Conduct. If a mentor needs to see your code, we’ll contact you with instructions.

Please post a screen capture image that shows any error messages or asserts you see.

As Tom points out, we can’t really see what course you are asking about, but one possible cause here is how the notebooks work: if you restart the notebook, you need to rerun all the previous cells. So where is find_closest_centroids defined? It must be in an earlier code cell. Did you run that cell? Just having the code sitting there does nothing until you actually run the cell in order to get it loaded into the runtime image. Try this:

Cell -> Run All Above

Then try running your failing test cell again.

If that doesn’t work, then you need to go back and look at the cell that defines find_closest_centroids. Maybe it has a syntax error, so running it just threw an error.

Here’s a topic on the DLS FAQ Thread which discusses the “function not defined” issue in a bit more detail.