Exercise 4: Tracking Down the Borrower - STUCK

Hi all,

Why is my code not working? I’ve been at this problem an hour now ad even the answers I put from ChatGPT is not working..

I even created the variable borrower_email=”arthur.dent@dlailibrary.com” to pass it and the homework still won’t accept it even though I get the right answer now.

START CODE HERE

Iterate through the borrowers_list

Look for ‘borrower’ in borrowers_list

Add your ‘for’ loop here

for borrower in borrowers_list:
if book[‘borrower’] == borrower[‘name’]:
borrower_email == borrower[‘email’]

Check if the name “book[‘borrower’]” equals “borrower[‘name’]”

Add your if statement here

    # Set "borrower_email" equals "borrower['email']"

END CODE HERE

Print the information

print(f"{book[‘borrower’]}'s email is: {borrower_email}")

Hi @agill407,

Please go through these common mistakes made by learners.

The “second point” applies to your situation here. The NameError: name test_your_code is not defined tells us that you have not ran the very first cell of the notebook which imports this for you.

And since you have been trying for a while, you might have made changes in your notebook which might not be easy to reverse, so I would recommend, once you have read the common mistakes, to start fresh on a blank notebook.

You can do that by opening the notebook and clicking on this option:

Screenshot 2026-02-10 at 12.51.18 PM

Best,
Mubsi

Every time you open a notebook, you must run all of the cells starting at the top.

This is because your saved notebook does not include the runtime environment. You must re-create this every time you open the notebook.