NameError: name 'test_your_code' is not defined in “Book Tracker” (Module 2: Automating Tasks with Python)

Hi all,
Course: AI Python for Beginners
Module: 2 – Automating Tasks with Python
Assessment: Book Tracker

All my assessments were correct, but I’m now getting this error everywhere:

NameError: name 'test_your_code' is not defined

  • I initially passed the first two assignments successfully.

  • When I moved on to assignments 3–5, this error started appearing.

  • I went back to re-run the first assignment (which had passed before), and it now shows the same error.

  • At this point, all my assignments show the same NameError.

I’m not sure how to proceed. Could this be an issue with the grader/helper not being loaded?

Things I’ve tried:

  • Restarted the kernel/runtime and ran all cells top-to-bottom.

  • Reopened the notebook and re-ran the setup/hidden cells (if any).

Request:

  • Guidance on how to re-load or re-import the grading helper (test_your_code)

  • If this is a platform issue, could someone reset the environment or advise a workaround?

Thanks

Hi @Guakona,

If you ran all the cells from top to bottom and this error appears still, then one possibility is that you accidentally deleted the test_your_code.py file from your workspace, or, you deleted the code cell/commented the code import test_your_code from within the notebook..

Open the assignment, on the top right, click on the help button (?), when the panel opens, click on Get latest version button. When the page reloads, try running all the cells again.

If the issue remains still, let me know.

Best,
Mubsi

Hi @Mubsi, thanks for the prompt reply. I am afraid I cannot ind the ‘get latest version’ button and there is no panel to open. Please see the printscreen below. Kind regards, Guakona

it also says that the save is disabled

Hi @Guakona,

You had selected the tag “coursera-platform”, hence my assumption and instructions were based on that.

But from your screenshot, I can see that you are taking the course on DeepLearning.AI’s learning platform.

Now, I was checking the course on the platform, and I came across the same issue as the one shared in your screenshot…the kernel is not connecting.

I have reported this to the team. I think because of this issue, you are having trouble in your assignments.

I’ll let you know once I hear back.

Thanks,
Mubsi

P.S I have changed your tag to “dl-ai-learning-platform”

Thank you so much. look forward to hearing from you in due course.

Hi @Guakona,

What browser are you using?

Also, could you try again.

Thanks,
Mubsi

Is the “?” (Lab Help) tool hiding underneath the “Try Again / Re-submit” button?

Hi @Mubsi Its Chrome and I tried reloading the page and executing the run function and it is the same output, I am afraid. regards, Guakona

Nope it is not :slight_smile:

Hi @Guakona,

Follow these instructions to get a fresh copy of everything in your workspace. You have to do step 5 as well. Basically delete everything and then do step 7.

Let me know if this helped.

Best,
Mubsi

Hi @Mubsi I had deleted the file and duplicated the original with the name indicated in the instructions. Now I can see and work in the notebook but the interface of DeepLearning ai shows 404

error

Hi @Guakona,

Click on the “Jupyter” logo. This will open your workspace. Once it opens, you’ll see C1M2_Assignment_original.ipynb. Make a copy of this notebook and rename it as C1M2_Assignment.ipynb. Then, refresh your page.

(C1M2_Assignment.ipynb is the name of the notebook your workspace expects. If you give it any other name, you’ll get the 404 error)

Best,
Mubsi

@Mubsi I have deleted it all again and created the file with the name you indicated, now it seems it works. thank you!

1 Like

Tip:
Never change the name of a notebook. It makes the grader unhappy.

@Mubsi hello! I have started working on the assignment and received exactly the same error as in my first message. I deleted all notebooks, duplicated the original and renamed to what you proposed. same result, what else can I do? this is time consuming….

Please run the very first code cell of the notebook, which is:

import test_your_code

It will also helpful to read through some of the common mistakes new programmers make in in this course.

Hi @Mubsi I have another issue now, sorry. I created new notebooks, passed all tests, submitted them only to find out that the I did not pass any. It also for some reasons do not save to the poem - could it be the problem of why the test fails? and what is going on?

Just guessing, I’m not a mentor for this course.

And maybe the file name needs to be in quotes (if the ‘file’ functions expect a text string rather than a variable name?

Again, just guessing.