I’m facing errors in the assignment even though my code shows the corrected output (same as the expected output for below Exercises. Please help as I’m unable to proceed with these errors. I have referred to other similar posts and tried multiple attempts to Restart, Shut down, Restart and Reconnect the Kernel. However, it doesn’t work.. Appreciate your support. Thanks.
Exercise 2: Is It On the Shelf?
Actual output from my code: Book is not available to be borrowed
Expected Output: Book is not available to be borrowed
Error from test_your_code.exercise_2() function:
Failed test case: Unable to detect valid if statement that checks if the book is on_shelf and is not on_hold.
Grader expected: a valid if statement that checks if the book is on_shelf and is not on_hold
You got: None
Exercise 3: On Hold or Overdue?
Output from my code: Book is overdue - Contact Arthur Dent to return it
Expected Output: Book is overdue - Contact Arthur Dent to return it
Error from test_your_code.exercise_3() function: Failed test case: Unable to detect valid if statement that checks if the book is overdue.
Grader expected: a valid if statement that checks if the book is overdue
You got: None
Error from test_your_exercise_4() function: Failed test case: Unable to detect if statement.
Grader expected: an if statement that checks the name of the borrower
You got: None
Yes it is “C1M2_Assignment” when I select the name of the exercise file. I have update it as “C1M2_Assignment.ipynb”, restarted the kernel, and run all the exercises. No luck. I still see the errors even when my code is correct with the exact expected output.
I saved with errors as I noticed a message “All tests passed”, and submitted the assignment and I am now able to notice a pass message and continue. However, it still shows errors from the test method.
Leaving this here for you and others encountering a similar issue:
After looking at your notebook here’s what I find.
Firstly, when I say make sure the notebook you are working in is called “C1M2_Assignment.ipynb” does not mean that you can create a new notebook and rename it as C1M2_Assignment.ipynb.
Without getting into much details, please remember the following:
Every time you click the button to open the assignment, a “default notebook” with the “default name” opens up. In this case, it is C1M2_Assignment.ipynb. That’s the notebook you should be working in because, for various purposes, each assignment notebook has some information stored in its metadata that is needed for tests and grading. When you get a new notebook and rename it as the default name, then it is a simple name change and no metadata is migrated.
Now let’s talk about the coding issues. Well, I will not call them “issues” really, because the codes perfectly fine, but in the scope of these assignments, the tests and grader are very particular about the exact code you write, and how you write it.
Through out the assignment, you have used brackets (). For example, to check if X is True you have done
if (X == True):
While this is correct, in the scope of the assignment, it is considered incorrect.
My problem is not with the if statement. It’s with the print statements. I do have 2 print statement and the output is correct, so I’m not sure where the problem is.