I am trying to print a quotation and the name of the author. My output should look something like the following (including the quotation):
Albert Einstein once said, "A person who never made a mistake never tried anything new."
I tried this:
quote = "A person who never made a mistake never tried anything new."
message = f"Albert Einstein once said, {quote}"
print(message)
But I am not getting quotation, the rest is fine I think.
You can do something like this:
>>> quote = "\"A person who never made a mistake never tried anything new.\""
>>> message = f"Albert Einstein once said, {quote}"
>>> print(message)
Albert Einstein once said, "A person who never made a mistake never tried anything new."
Or you can also do something like this:
>>> quote = "A person who never made a mistake never tried anything new."
>>> message = f"Albert Einstein once said, \"{quote}\""
>>> print(message)
Albert Einstein once said, "A person who never made a mistake never tried anything new."
Or you can wrap the double quotes with a single quote to get you to print the double quotes.
Do something like this:
>>> quote = '"A person who never made a mistake never tried anything new."'
>>> message = f"Albert Einstein once said, {quote}"
>>> print(message)
Albert Einstein once said, "A person who never made a mistake never tried anything new."
Note that if you have a single quote inside your sentence, then it will not work. For example, if your sentence said
"A person who's never made a mistake never tried anything new"
, then the single quote won't work.