Question regarding book grader assignment- 4th exercise in 2nd module

**Question regarding 4th exercise on book tracker assignment (module #2, last assignment)

(Solution code removed, as posting it publicly is against the honour code of this community, regardless if it is correct or not. You can share the errors you get)

This is the error:
TypeError Traceback (most recent call last)
Cell In[27], line 8
1 ### START CODE HERE ###
2 #print(f"name is {book[‘borrower’]}“)
3 # Iterate through the borrowers_list
4 # Look for ‘borrower’ in `borrowers_list`
5 # Add your ‘for’ loop here
7 for borrower in borrowers_list:
----> 8 if book[‘borrower’]==borrowers_list[‘name’]:
9 borrower_email= borrowers_list[‘email’]
10 print(f”{book[‘borrower’]}'s mail is: {borrower_email}")

TypeError: list indices must be integers or slices, not str

General comment: The chat response did not help me solve it, also, not clear to my why is the FOR loop needed here.

Hi @Mayshi,

I have removed the solution code you had shared, as sharing it is against the code of conduct of this community.

As for your mistake, it is in the “if” statment you had written.

Pay close attention to how you wrote it and what the exercise instructions say, especially the code comment:

# Check if the name "book['borrower']" equals "borrower['name']"

Best,
Mubsi

oh, sorry about the code! And thank you for the reply!

1 Like