Definition Errors

Hi all -

I keep getting these variable not defined errors in my assignment. Any suggestions here? I think the code itself is fine but there are small issues that won’t allow it to pass the checks.

Thank you!

  • RE

It looks possible the entire code may not have been pasted here (there is no # START CODE tag, for example, or # GRADED FUNCTION indication. But the symptom is that you are using a variable that doesn’t have function scope. Namely, label, which is defined outside the function, is referenced inside it. The autograder executes each of your graded functions independently from the notebook in which they are submitted. This it what it means in so many of these discussion threads where mentors advise don’t use global variables.. You should only use variables passed to the function as parameters or with local scope.

@ai_curious explained it preety well and clearly. I hope it helps to get the query cleared
If the issue still persists please do let us know
Also if possible and not necessary please do not declare new variables(either global or local)

Thanks for that - i tried updating the notebook and still not having any luck. I didn’t realize the hashtags helped with the automatic grading. Is there a way to completely reset the notebook so I can start fresh?

I have my code saved in colab so want to try carrying it over into a new assignment notebook so I can be more mindful of the hashtags.

Thank you for the advice!

Covered in one of the FAQs here->

Thank you! I’m slowly getting there.

Now I’m getting an error that says “there was a problem grading your submission” See screenshots for details.

My code is matching the expected output in the notebook so don’t believe anything is wrong with my code but i also don’t know how to resolve the error so I can pass the checks. Any advice? Thanks everyone!

you are hard coding maxlen. Notice that the value you assigned shows up in the grader error message.

Remember that in the autograder the test data and conditions can be different than what you have locally in the notebook. You should refrain from using magik numbers like that in graded functions and instead get a value dynamically from the variables in the function itself. Hope this helps.

You are a lifesaver - thank you!

1 Like