# find and remove "\" character from string

I V ivlenin at gmail.com
Sat Sep 15 22:33:27 CEST 2007

```On Sat, 15 Sep 2007 19:34:45 +0300, Konstantinos Pachopoulos wrote:
> Hi,
> i have the following string s and the following code, which doesn't
> successfully remove the "\", but sucessfully removes the "\\".

There is no \\ in the string; there's one \ , which gets succesfully
removed.

When you write a string in the source code \\ gets changed to \ and \a
gets changed to "ASCII Bell (BEL)" (that's what the docs say), which is a
(non-printable) control code that is supposed to make the terminal beep.

>  >>> newS=""
>  >>> for i in s:
> ...     if i!="\\":

Here, your test is true if i is not \

> ...             newS=newS+i
> ...
>  >>> newS