I can't test my code because the document doesn't recognise np (week 2)

When I try to run my code within the Python basics with numpy, I keep getting this error
“NameError: name ‘np’ is not defined”. This error is always attached to the 2nd section of any exercise in the document, which is a prewritten part that I am no supposed to edit.
Even in tutorial areas that are separate from an exercise, this error shows up.
Is this due to an error in the document that means the numpy addon isnt actually present or have I missed something I was supposed to do to make the code runnable?

Hi @jethorpe; welcome to the Specialization. You have probably not run the very first cell that contains a bunch of import statement. One of these will be import numpy as np.

1 Like

Thank you! I hadn’t realised that I needed to run that part but it works now.

Hi Ken,

Just wanted to give you some thanks for this Occam’s razor type explanation – I just spent five hours trying a half-dozen different code adjustments to get np.array to be recognized in Exercise 7…and all I needed to do was remember to initialize all prior cells when coming back to the notebook.

I feel very foolish, but I guess that’s why we practice it. Thank you again for your help.

Hi Matthew,

Indeed! Lessons never to be forgotten–we’ve all been there. :dizzy_face: The weekend is here in time for you to recover!