Need assistance figuring out AI Python for Beginners exam "Working with a Virtual Library"

I am having a rough time figuring out exercise 2 & 3. I keep getting the error messages: Exercise 2:



# Test your code!
test_your_code.exercise_2(available_copies)  
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In [13], line 2
      1 # Test your code!
----> 2 test_your_code.exercise_2(available_copies)  

NameError: name 'test_your_code' is not defined


Exercise 3: NameError Traceback (most recent call last)
Cell In [15], line 2
1 # Test your code!
-—> 2 test_your_code.exercise_3(requested_book)

NameError: name ‘test_your_code’ is not defined

That test_your_code item was imported by an earlier cell in the notebook. That error probably just means that you haven’t run the previous cells in the notebook. You need to rerun all cells every time you reopen or restart the notebook. Note that if you leave it open, but idle, for more than a few minutes, the “Kernel” can shut down and you need to rerun everything from scratch.

Try this and see if it helps:

Kernel -> Restart and Clear Output
Cell -> Run All Above

Then run the test cell again and see if it changes the behavior. If it still fails after the “Run All Above”, then the next theory would be that your notebook has been damaged: e.g. some code cell has been accidentally deleted or changed to a “Markdown” cell.

But let’s try the easy solution first and go from there …