- 2

How to enclose a double quoted string into a double quoted string?

4th Jun 2021, 1:14 PM
Swethasenthil
6 odpowiedzi
+ 5
Swethasenthil , you can use single quotes as outer quotes, and double quotes for the inner quotes: print ('The number: "36"')
4th Jun 2021, 2:29 PM
Lothar
Lothar - avatar
+ 2
Using double quote inside double quote raise an error similar to single quote. You have to use "\" here . print("the number is\"36\"")
4th Jun 2021, 1:33 PM
TOLUENE
TOLUENE - avatar
+ 1
It was like ... print ("The number: "36"") What is the error..
4th Jun 2021, 1:24 PM
Swethasenthil
+ 1
This is a very simple fix. If you don't want to use single quotes, then you can use python's escape character, the backslash. The solution for your example is print("The number: \"36\"") You place the backslash directly before the character you want to print. For example, a new line is "\n", a tab is "\t", double quote "\"", single quote "\'".
4th Jun 2021, 5:58 PM
Zibblobet
Zibblobet - avatar
0
Make use of escape sequences . eg , "\" Something\""
4th Jun 2021, 1:18 PM
Abhay
Abhay - avatar
0
I can't undestand what you want to say.
4th Jun 2021, 1:18 PM
Yash Wable 🇮🇳
Yash Wable 🇮🇳 - avatar