Greetings Mentor,
I’m a couple of weeks into this DLS course and am continuously facing a “NameError” in my code. I cannot edit the 2nd block of this code. Please help me resolve it.
Thank You.

NameError Traceback (most recent call last)
3 print("normalizeRows(x) = " + str(normalize_rows(x)))
----> 5 normalizeRows_test(normalize_rows)

NameError: name ‘normalizeRows_test’ is not defined

Are you executing the line which imports that function?

from public_tests import *

Great! It’s working now, thank you.
But I did execute it in one of the earlier blocks, shouldn’t it be working without me having to execute this line again and again in every exercise code?

Yes, it should work as part of the cell where it was originally defined. Could it be that you had passed already that part of the assignment and when you opened it again you didn’t execute previous cells?

Possibly, thanks for your input. I’ll let you know if this issue persists.

i had a similar error and importing from public_tests import *into the code block resolved the error. I’m confused why we had to do this.

I thought we are only suppose to add code where it explicitly asks for it.
(i.e. between where it says # YOUR CODE STARTS HERE and # YOUR CODE ENDS HERE. This seems like a random addition and doesn’t test for the concepts (i.e. normalization) being covered on the exercise and seems like a random bug patch. any clarification? thank you.

Hello @PD_Vaillancourt,

Welcome to our community!

When we first open the notebook, the two imports are already there in the 3rd and the 6th code cells respectively (check whether they are still there in your notebook). Therefore, if we have run all the code cells in order, they will have been imported and there is no need to add them yourself before def normalize_rows(x).

It is a good practice that every time we open or reopen a notebook, or every time we restart the notebook’s kernel, we run all the cells from top to bottom to make sure everything is defined and is defined in order.

Code cell number 3:

Code cell number 6:


1 Like