Question: So I can't seem to figure this out... I have a string say, `"a\\nb"` and I want this to become `"a\nb"`. I've tried all the following and none seem to work;

```
>>> a
'a\\nb'
>>> a.replace("\\","\")
  File "<stdin>", line 1
    a.replace("\\","\")
                      ^
SyntaxError: EOL while scanning string literal
>>> a.replace("\\",r"\")
  File "<stdin>", line 1
    a.replace("\\",r"\")
                       ^
SyntaxError: EOL while scanning string literal
>>> a.replace("\\",r"\\")
'a\\\\nb'
>>> a.replace("\\","\\")
'a\\nb'

```

I really don't understand why the last one works, because this works fine:

```
>>> a.replace("\\","%")
'a%nb'

```

Is there something I'm missing here?

**EDIT** I understand that \ is an escape character. What I'm trying to do here is turn all `\\n` `\\t` etc. into `\n` `\t` etc. and replace doesn't seem to be working the way I imagined it would.

```
>>> a = "a\\nb"
>>> b = "a\nb"
>>> print a
a\nb
>>> print b
a
b
>>> a.replace("\\","\\")
'a\\nb'
>>> a.replace("\\\\","\\")
'a\\nb'

```

I want string a to look like string b. But replace isn't replacing slashes like I thought it would.

Answer: 
Your original string, `a = 'a\\nb'` does not actually have two `'\'` characters, the first one is an escape for the latter. If you do, `print a`, you'll see that you actually have only one `'\'` character.

```
>>> a = 'a\\nb'
>>> print a
a\nb

```

If, however, what you mean is to interpret the `'\n'` as a newline character, without escaping the slash, then:

```
>>> b = a.replace('\\n', '\n')
>>> b
'a\nb'
>>> print b
a
b

```
In Python string literals, backslash is an escape character. This is also true when the interactive prompt shows you the value of a string. It will give you the literal code representation of the string. Use the `print` statement to see what the string actually looks like.

This example shows the difference:

```
>>> '\\'
'\\'
>>> print '\\'
\

```