Hello DeepLearning .AI community,
I have been stuck on this code for awhile. I get output, but not the right output. Not sure what I am missing. Any insights would be appreciated!
Thank you!
Hasse
Hi @Hasse_LP,
Looking at what you have shared, there are a few syntax bugs tripping up your code. Let me break them down:
Variables vs. Strings: In your if statement, you wrote "book['overdue']" == True. By putting quotes around "book['overdue']", Python treats it as a literal string of text, rather than looking inside the book dictionary for the actual value. To check the dictionary, you just need to remove the quotes: if book['overdue'] == True:.
Assignment (=) vs. Comparison (==): Under your else statement, you have "book ['on_hold']" == True. The double equals sign (==) is used to ask a question (e.g., “Is this equal to True?”), but here you want to assign a value to update the book’s status. You need a single equals sign (=) for assignment. (You also need to remove the quotes here as well).
Looking at a few of these mix-ups, it seems like some of the foundational syntax rules might still be a little fuzzy to you, and that’s completely okay!
Programming is genuinely tough, and it’s like learning a brand-new language. Because of that, the absolute best thing you can do right now is to go back and review the lesson videos and labs on dictionaries, variables, and conditionals.
While you could just apply the fixes I pointed out above and jump to the next task, I strongly advise against forcing yourself to move ahead. In programming, everything builds directly on top of these basic concepts. If you try to push forward without fully understanding them first, the next exercises and assignments will only get more frustrating and you might not have learnt from this course as much as you’d have hoped for.
It is completely normal and expected to have to go over the basics many times before it all clicks and becomes muscle memory. Taking a step back to relearn and truly understand this foundation now is the smartest move you can make. It will make all the upcoming lessons and assignments easier to follow and attempt. Take your time with it!
Best,
Mubsi
Hello Mubsi,
Thank you for the feedback. Yes. I agree that reviewing this section again will be helpful.
Best,
Hasse