0
Create a string containing a double quote
3 Réponses
+ 2
If you have to use single / double quotes in a string, just use the type of quotes that are NOT used in the string. For example:
singleQuoteInside = "'Single quotes are a part of string so double quotes are used outside'";
singleQuoteOutside = ' "Double quotes used inside so single quotes outside " '
+ 2
And for a string containing both single and double quotes, many ways to achieve this:
"The man said: \"What's for?\""
'The man said: "What\'s for?"
... or even:
"""The man said: "What's for?"""" # EDIT: in fact this one cause an error with the fourth ending double quote :P
'''The man said: "What's for?"'''
0
string = ' "Hello, world! " '
print(string)