Why is my answer not valid? format()

def poem_title_card(poet, title):

return “The poem {} is written by {}.”.format(title, poet)

print(poem_title_card(“Walt Whitman”, “I Hear America Singing”))

I am printing the correct answer and it won’t let me move forward.

Double check the hint and the requirement.


You can view the solution if you are really desperate. Then you can make out that your mistake is. I hope you find out your issue.

Happy coding! :wave:

1 Like

Hello @baezh, welcome to the forums. If you check the CC error message as @tgrtim said, you will see that the problem is with your string (nothing to do with your code-that’s fine!) It wants:
"The poem "I Hear America Sining" is written by Walk Whitman." (notice the "" around the title of the poem?

You are printning:
"The poem I Hear America Sining is written by Walk Whitman." (notice the lack of "" around the title of the poem?

That is the only problem; you aren’t printing the exact string it wants (I suspect the lesson wants you to make use of an escape character to allow for the "" in the middle.)

How to use the escape character, if you need to:
#excuse the arbitrary example
print("a, b, \"c\".")#notice the backslashes (\)? They are escape characters. This would print: "a, b, "c".

I hope this helps!


Hello @codeneutrino, Thanks for your answer, I have to reinforce that topic. :man_technologist:

1 Like