C1 - Week 3 Programming Assignment: All Tests Pass. But getting compile error on submit

Error: “Cell #14. Can’t compile the student’s code. Error: TypeError(“unsupported operand type(s) for +=: ‘NoneType’ and ‘NoneType’”)”

All tests pass when run in Notebook.

Not 100% sure which cell is cell#14. I’ve tried finding all instances of “+=” and using intermediate variable. Still getting same error.

Hi @otto_ai,

To find cell #14,

  1. open the notebook
  2. click “Kernel” > “Restart and run all”
  3. every cell that finished running will show a number in its left:
  4. follow the numbers to cell #14
  5. it’s very likely that you will find error message below cell #14 as well, so use the information provided to you from the Traceback to locate the error.

Good luck!

Hi - that unfortunately made me lose most of my work. Is there any way of retrieving it?

Never mind. I rewrote it quickly. All good now.

Strange to hear that my steps removed any of your work, because they only rerun your code.

In the process, they will remove the outputs of all of the cells, but never your code. Moreover, all correct outputs will be regenerated automatically if nothing is wrong in your code.

In fact, behind the scene, the autograder does that too, so the autograder can run your notebook successfully only if you can rerun it successfully - that is why I wanted you to demonstrate that to yourself :wink: (and find the cell #14 by the way)

Perhaps my above clarification is more for learners who may find this thread in the future, because you have already shared the good news with us - it’s all good now. :wink:


I am exactly in the same situation. My code passes all tests, but I also get that error message when submitting.

Copy your code before following the @rmwkwok directions above.

I just reset the notebook and started again. Everything is fine now.
Thank you.

I get the exact same error. All the tests pass when run in Notebook. I followed the instructions in this post, but still I am getting the same error. I don’t have a single ‘+=’ in my notebook, but the error seems related to ‘+=’.
Please help!

I found the problem. I had saved the Notebook by a different name. once I opened the original Notebook and added my lines of code and submitted it, everything was fine.