- 3
HEY GUYS I AM NEW TO PYTHON and having a problem in string please help me
<<< " " ?and the question is create a string containing a double quote ?
3 Answers
0
Strings
Some characters can't be directly included in a string. For instance, double quotes can't be directly included in a double quote string; this would cause it to end prematurely.
Characters like these must be escaped by placing a backslash before them.
Other common characters that must be escaped are newlines and backslashes.
Double quotes only need to be escaped in double quote strings, and the same is true for single quote strings.
let me show you how to this
print("\" \"")
done
these are called escape sequence in c++
0
Complete the code to create a string containing a double quote.
- 1
if you don't want to use backslashes to escape the double quotes, you can use single quotes instead. this allows the string to contain double quotes.
single quoted string -> allow double quotes inside
double quoted string -> allow single quotes inside
print(' "quoted string" ')
print(" 'quoted string' ")