I have a string that contains quotes like this:
string = \"\\\"This is my mom\'s vase\\\", said Kevin.\"
Problem is when I use it as a stri
What you're seeing is the representation of your string as produced by the repr function. repr outputs strings in such a way that they're valid python literals; in other words, you can copy/paste the output of repr(string) into a python program without getting a syntax error:
>>> string
'"This is my mom\'s vase", said Kevin.'
>>> '"This is my mom\'s vase", said Kevin.' # it's valid python code!
'"This is my mom\'s vase", said Kevin.'
Because your string contains both single quotes ' and double quotes ", python has to escape one of those quotes in order to produce a valid string literal. The same way you escaped your double quotes with backslashes:
"\"This is my mom's vase\", said Kevin."
Python instead chooses to escape the single quotes:
'"This is my mom\'s vase", said Kevin.'
Of course, both of these strings are completely identical. Those backslashes are only there for escaping purposes, they don't actually exist in the string. You can confirm this by printing the string, which outputs the string's real value:
>>> print(string)
"This is my mom's vase", said Kevin.
There's nothing to solve! What are you still doing here? Scroll up and read the explanation again!