When I want to do a print
command in Python and I need to use quotation marks, I don't know how to do it without closing the string.
For instance:
print " "a word that needs quotation marks" "
But when I try to do what I did above, I end up closing the string and I can't put the word I need between quotation marks.
How can I do that?
If the quotation enclosed in single marks also contains material–whether another quotation or the title of a work–that needs to be set off with quotation marks, use double quotation marks around that material. The pattern is double, single, double quotation marks.
Quoting a Quote That is to say, what do you do when you're quoting material that already contains a quote? The principle doesn't change. In American English, use double quotes for the outside quote and single quotes for the inside quote. In British English, do the opposite.
Do commas and periods go inside or outside quotation marks? Commas and periods always go inside the quotation marks in American English; dashes, colons, and semicolons almost always go outside the quotation marks; question marks and exclamation marks sometimes go inside, sometimes stay outside.
'” When multiple quotation marks are used for quotations within quotations, keep the quotation marks together (put periods and commas inside both; put semi-colons, colons, etc., outside both).
You could do this in one of three ways:
Use single and double quotes together:
print('"A word that needs quotation marks"') "A word that needs quotation marks"
Escape the double quotes within the string:
print("\"A word that needs quotation marks\"") "A word that needs quotation marks"
Use triple-quoted strings:
print(""" "A word that needs quotation marks" """) "A word that needs quotation marks"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With