Reputation: 97
print(''What is "program"?'')
I'm required to use double quotations either 2 apostrophes ('') or 2 quotation marks ("") to print this string, but the quotes on program creates a syntax error. I tried using backslash before the " to ignore them, but that doesn't work either
Upvotes: 0
Views: 5935
Reputation: 71
Using Triple Quote is the most easiest way without remembering where to put extra / Try This:
print('''What is "program"?''')
Upvotes: 0
Reputation: 22953
You have two options for printing double quotes in Python.
You can use the escape character(\
) to escape the double quotes, telling Python that they are not "special":
print("What is the \"program\"")
Or you can take advantage of the fact that single quoted strings can contain double quotes and their is no need to escape them:
print('What is the "program"')
Upvotes: 5