0

Create a string containing a double quote

20th Feb 2017, 6:57 AM
deepu c
deepu c - avatar
3 odpowiedzi
+ 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 " '
20th Feb 2017, 7:59 AM
Chirag Bhansali
Chirag Bhansali - avatar
+ 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?"'''
20th Feb 2017, 8:42 AM
visph
visph - avatar
0
string = ' "Hello, world! " ' print(string)
20th Feb 2017, 7:12 AM
Leshark
Leshark - avatar