Strange Error in K-Means Assignment

I ran into this error when I was submitting my K-Means assignment.
All tests have passed, I even tried a different implementation, all tests passed again.
But I still get the same error that I don’t know how to even debug.
Cell #2. Can’t compile the student’s code. Error: SyntaxError(‘unexpected EOF while parsing’, (‘/tmp/student_solution_cells/cell_2.py’, 7, 5, ’ \n’))

Thank you.

Hello @Ahmed_Mostafa3,

  1. Go to the notebook on coursera, click “Kernel” > “Restart & Run all”. The code cells will run one after one and completed cell will show a number in the left such as In [1]:
    Screenshot from 2022-09-29 07-41-55

  2. As in the error message, it is Cell #2 that causes the problem, so you will need to go to In [2] and you should see an error traceback beneath the code cell. Up to now you know where the error locates/is triggered, and you have the error traceback as an additional piece of information for you to debug.

  3. Google the error message you see beneath the code cell. For example, google “SyntaxError('unexpected …”, and read posts about it. It’s not unusal that sometimes you will need to read more than 5 or 10 posts before fully understanding it.

Good luck!
Raymond

Thank you @rmwkwok It’s fixed! :slight_smile:
I though that cell #2 meant The 2nd graded function.
Strange thing is that there were no errors in any cell, and all tests have passed. And cell #2 was a cell that I created to test something, and it had no errors. so I removed it, and got a whole new error.
So like a real programmer, I changed absolutely nothing, and ran it again. and voila! it worked lol.

Hello @Ahmed_Mostafa3, it’s good to know it worked!

I love testing things myself, but I have also heard that creating code cells myself may end up not good with the grader so I also always remove those cells (or at least commenting out those cells, whichever way works).

Anyway, testing something ourselves is more important, and the grader is less :grin:

Cheers,
Raymond

PS: can’t explain what happened to exactly your case but you passed the assignment, and you learned from your tests, and that’s good!