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?
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"