I’m so confused… why/how is a different from b?! Why don’t they print the same thing?
>>> a = '"'
>>> a
'"'
>>> b = "'"
>>> b
"'"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The strings are not presented differently. Their presentation is just adjusted to avoid having to quote the contained quote. Both
'and"are legal string literal delimiters.Note that the contents of the string are very different.
"is not the same string as';a == bis (patently)False.Python would have to use a
\backslash for the"or'character otherwise. If you use both characters in a string, then python is forced to use quoting:As you can see, the string representation used by Python still uses single quotes and a backslash to represent that last string.