C1M2 Exercise 3, "TypeError: 'str' object is not callable"

I’ve copied code from other exercises aswell as lessons and it keeps saying
“TypeError: ‘str’ object is not callable”
full code
if book[“overdue”]:
print(f"Book is overdue - contact Author Dent to return it")
else:
if book[“on_hold”]:
print(“Book has been put on hold”)

Please post a screen capture image that shows the entire error message.
Not a text copy-and-paste.

Hello!! some of the possibilities could be:

If the book dictionary keys ("overdue" or "on_hold") do not hold boolean values but strings (e.g., "True" instead of True).

If a variable named book is reassigned to a string or another non-dictionary value.

book = {"overdue": True, "on_hold": False}
book = "some string"  # This will cause an issue

Also verify that all quotes, brackets, and parentheses are properly used.

2 Likes

Thank you, i ended up fixing it. It was some sort glitch, i ended up closing a reopening the assignment and it sorted itself out. I’ve now completed the assignment and it says “All tests passed!” under each exercise however whenever I submit it, it says that i have scored 0/50. I’ve gone to the ‘my submissions’ tab and clicked on ‘show grader output’ and the message that i get is “There was a problem compiling the code from your notebook, please check that you saved before submitting. Details:
unexpected indent (, line 16)”. I have submitted again after running each exercise causing there to no longer be a ‘line 16’ and yet it keeps giving me the same grader output message. I’m not sure what to do next about it so for now I’m continuing on to module 3.

Hi @Harry_culpan00,

I’m going to direct message you regarding this

1 Like

Harry was using code that was hard-coded and not working well with the sensitivity of the tests. Fixing this helped remove the errors.

1 Like