Week 1 - Graded Code Assignment - Exercise 2

Hello Instructors,

I tried to attempt Exercise 2 for Week 1 - Graded Code Assignment relating to the AI Python for Beginners Course.

I did get the write outcome with my code, but the check component gives an error, appreciate if any body can help, please see picture below.

(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)

But when I try to check it, then it gives me an error, do not know what to do.

Can anybody help as I am unable to proceed with the Graded Assignment.

Thank you in advance.

Stan

Two (actually three) tips:

One: In your line of code to reduce the number of available_copies, do not include the formatting string “f{…}”. That is only used inside a print() statement. Just modify the variable itself, using a subtraction operator (like this: “variable = variable - 1”

Two: The error with “test your code” means that you have not run the cell that imports that asset. Every time you open a notebook, you must run all of the cells starting from the top of the page. That is where the assets are imported.

Three: In the future, please do not share your code on the forum. That is not allowed by the Code of Conduct. Only include images of your test results or error messages. That is usually enough to diagnose the issue.

And, a fourth comment on programming style:
In the format specification inside the print() statement, only use one quote, not three.

Generally when you use three quotes, in the Python language that is a block comment, and none of the code that follows it will be run.

Thank You Tom for your Guidance and advice, it was really helpful and it worked. I am new to the whole process, so my apologies for posting the code and will make sure will not post it again in the future.

Thank you for all your help.

Stan

No problem, and that’s good news you were able to forge ahead.