Week 1 first programming assessment

First, just so you know, it’s against community guidelines to share the portion of the code you’ve written. It’s OK in this case, since it looks like you’ve just copy/pasted from the hints, but keep this in mind for the future. Instead of sharing your code, you can share the error. If a mentor needs to see more, they might ask you to send them your code in a direct message.

So… what I see here is a couple of issues:
1). It looks like you accidentally indented the “for j in range …” portion too much, it should be at the same indentation level as the line above it. Python is very sensitive to indentation, so you need to be extra careful about it.

2). It looks like you copied the first level of hints, which is not completely finished. You still need to fill in the parts that are marked with comments that say you need to fill in that part. In particular, where it says:

# Your code to calculate the norm between (X[i] - centroids[j])

and

# Your code here to calculate index of minimum value in distance

You need to fill in those parts with your own code. If you need help with that, there are further hints you can click on to get more detailed help.

I hope this helps. If you’re new to python, you might want to take some time to get a little python experience. That could include going back and starting with course 1 (this is course 3). Course 1 gives you a little more gentle intro to python and jupyter notebooks. Beyond this, especially if you are also new to programming, you might want to take some time out to do some background learning for Python. You can check out the “References for self-learning” section of the FAQ for some more specific suggestions:

FAQ References for Self-Learning

1 Like