0

How can I use the double quatation symbol in a string

27th Apr 2020, 1:28 PM
Ddungu Imran
Ddungu Imran - avatar
5 Answers
+ 4
In Python use a backslash \". or put the double quotes in a single quote print('"name"') print("\"name\"")
27th Apr 2020, 1:32 PM
Justus
Justus - avatar
0
In Python, the escaping method is \. One can escape "" or '' using this. For eg. print("this is a \"human\"")
27th Apr 2020, 5:41 PM
Varun Vaswani
Varun Vaswani - avatar
0
Another alternative in python is to use triple quotes (either single or double, but obviously same type at start and end): print("""no needs to escape " (double quote) nor ' (single quote)""") print('''no needs to escape " (double quote) nor ' (single quote)''')
27th Apr 2020, 8:00 PM
visph
visph - avatar
0
Varun Vaswani triple quotes literal string are meant for do multiline strings and comments, and a literal string is totaly valid as argument of any function, even the print() function ^^
28th Apr 2020, 6:30 AM
visph
visph - avatar
- 1
visph , one can't use "' for print and other strings since in the syntax, it's meant for do strings or multiline comments...
28th Apr 2020, 3:14 AM
Varun Vaswani
Varun Vaswani - avatar