0
use of backslah
The preparation kit just had this question Complete the code to create a string containing a double quote. >>> "--" ans: \" why wouldn't the answer be just ( " ) and why it needs a back slash
1 Respuesta
+ 3
(") is a double quote within parentheses. It's not a string, let alone a string containing a double quote. In fact, it doesn't quite mean anything in Python, hence it can't possibly be the answer.
Certain characters are illegal in a string. A string containing a double quote would look like
"""
if unescaped. To the interpreter, this looks like a triple quote. Instead, you escape the double quote using a backslash.
"\""
so that the interpreter understands that the double quote is part of the string instead of a closing quote.
https://www.w3schools.com/python/gloss_python_escape_characters.asp