I’m stuck on the final assignment question for week 1.
The Aim: * The printed message should be in the format using multi-line f-string as, <Requested Book> is currently unavailable. You can request it from the library.
My code or answer is:
### START CODE HERE ###
# mentor edit: code removed
### END CODE HERE ###
Problem: My code does not seem to work but I can’t figure out why.
Anyone have any tips?
Thanks so much for replying. I have made the suggested edits but same issue.
I have decided to use a clean notebook as I think it could be the missing run button.
In the new notebook - I now get the following error message for each question from Exercise 1B onwards:
“Failed test case: There was no output for exercise 1b cell, check that you run it.
Grader expected: An output generated from print statements
You got: None”
I had passed Exercise 1B and Exercise 2 previously and used the same code.
Any tips?
Thanks in advance.
hi @Milo2 , the error say that is not getting any output, remember to run each cell from top to bottom if anything is stoping it from working, like a missed libraries, a missing definition… also the error say that expect the answer/output on a print statement, so make sure you are correctly passing the output to a print(), f-strings, are string that can have variables inside as the next example that would print the current date with a text string, in this case the variable is a function but can just be another string or number… date = 31/5/2025 (this is not dynamic)
def get_current_date_string():
"""
Returns the current date formatted as 'YYYY-MM-DD'.
"""
now = datetime.datetime.now()
return now.strftime("%Y-%m-%d")
# Get the current date using our function
current_date = get_current_date_string()
# Create the f-string with the embedded date
message = f"Hello world {current_date}!!!"
This explanation is helpful for learners and contributes to their understanding. However, please keep in mind that sharing code publicly in this community violates our code of conduct. Kindly refrain from doing so in the future..
@Girjesh, hi!!!
Are you sure? I thought that because it is not from the course, it could be shared, as it is just an example of how f-strings work, I thought only the code from the course could not be shared (and being more specific, code with answers from the course)
The Code of Conduct only applies to code for the programming assignments, not all code in general.
If your code can be applied directly to solve a graded assignment, the Code of Conduct would still apply. This covers superficial masking such as modifying a variable or function name, etc.