I completed Module 3, Working with your own data and documents in Python. I ran all the code and at the end of each exercise it displayed all tests passed. I submitted the assignment and got zero points per exercise. Each exercise displays the same error message: name ‘key_topics’ is not defined. Three of exercises do not require a key topic and the ones that do I defined the topics and passed the assignment. Can someone have a look and see why this is occurring? Thank you.
Hi @Lou4,
I’m going to send you a direct message regarding this.
This issue happens because you have defined key_topics dynamically using the response variable (for example, by parsing or splitting response inside the cell) instead of copy-pasting the topics as literal strings.
While this works locally in your active notebook session, the Coursera/deeplearning.ai autograder runs in a clean, sandboxed environment. In that environment, the cell that calls the LLM to define response is not marked as graded and is not executed. Furthermore, the autograder does not have internet access to run LLM API calls.
Because response is not defined in the grader’s environment, the cell for Exercise 2 fails to execute. This means the key_topics variable is never created, which causes the subsequent cells and the grader tests to throw the NameError: name 'key_topics' is not defined error. If any cell crashes during execution, the grader fails the entire submission and shows a score of 0.
You can check this community thread where @Mubsi resolved the exact same issue.
To fix this, copy the three topic strings generated by the LLM and paste them directly as string literals inside the list in Exercise 2:
key_topics = [
### START CODE HERE ###
"Topic 1 text",
"Topic 2 text",
"Topic 3 text"
### END CODE HERE ###
]
Thanks for the reply. I understand now why this is occurring. But the cell will now no longer let me make any edits to the existing text.
Lou Gleason
Hi @Lou4,
This means you are not allowed to change that cell. Please only make changes in cells that are exercise cells. Please be sure to follow all of the instructions provided under, INSTRUCTIONS FOR ATTEMPTING THE ASSIGNMENT instructions at the top of the notebook.
Thanks for your help. I did what you said and still the same result. So I am definitely missing something. Am I just missing the entire picture here? Am I way off base? Starting to feel that way. It looks correct to me the very way the grader wants it, but obviously it is not. Any help will be appreciated.
Lou Gleason
lougleason@mac.com
Yes, you are correct I was referring to the wrong cell. I thought I saw my error, and after several attempts to fix. I still get the same error message on all activities within the assignment, and I still fail with zero points for each activity. Any help is appreciated.
Verify the following steps to resolve this:
- Save the notebook: Coursera evaluates the saved
.ipynbfile on disk. Manually save the notebook (Ctrl + Sor File → Save and Checkpoint) before submitting. - Check for variable typos: Ensure the variable is defined exactly as
key_topics(lowercase, plural, with an underscore). A typo likekey_topicorkeytopicswill trigger this error. - Placement within code cells: Your definition must be inside the designated exercise cell between the
# START CODE HEREand# END CODE HEREcomments. If you added a new cell or defined the variable outside these boundaries, the grader will skip it. - Resolve errors in previous cells: Run the entire notebook sequentially from the top (Kernel → Restart & Run All). If any preceding cell fails or throws an error, execution stops and subsequent variables like
key_topicsare never defined. - Sync a clean workspace: If cells have been deleted, moved, or the notebook structure is corrupted, rename your current notebook as a backup. Then, use Lab Help → Get Latest Version to get a clean template, and copy your code solutions back into the designated exercise blocks.
Thanks for your assistance. I did all this and same result. I am trying to contact Coursera but I dont see anywhere to do that, nor do I have the option in this assignment to opt to a peer review. This is getting frustrating. I know it is not the end of the world but I would like to get the full credit. I am nervous now that if I take other courses the same thing will happen. Any advice?
@Mubsi @chris.favila - Could you please look into this? The learner has tried all the standard troubleshooting steps (saving, restarting kernel, syncing workspace) and is still getting error. This looks like it may need a backend workspace inspection to identify the root cause.
Hi @Lou4,
After looking at your notebook, these are the mistakes I could find which is likely causing the grader to fail.
Please remember, the notebook and the grader run in different environments. The grader does not have the same resources as the environment in which the notebooks runs is. What this means is, if you are passing the test in the notebook for the wrong reasons, the grader will fail you. In order for your solution to be truly correct, it needs to pass the notebook tests as well as the grader tests.
Exercise 1
-
You have renamed the function parameter to a different variable name. NEVER do that. Changing things which should not be changed will cause you all sorts of issues. As you can see, you are already unable to figure out what’s going wrong.
Only ever change/implement code which you are suppose to between the tags:
### START CODE HERE ### ### END CODE HERE ### -
You are passing in the hardcoded text file name (
news_article.txt) instead of using the function parameter. Never hard code anything unless specifically asked to.
Exercise 3
Instead of using the key_topics list to extract the topics as per the exercise instructions, you are again hardcoding the topics in this exercise.
Please follow the exercise instructions and implement code as instructed. Fixing these should get you to be able to pass the grader.
Best,
Mubsi
Run it in Claude and give detailed prompt just how you stated and have Claude double-chceck as to why it may have been a Zero.