On Sun, Dec 8, 2013 at 11:59 AM, Mahan Marwat <mahanmar...@gmail.com> wrote: > Why this is not working. > >>>> 'Hello, \\\\World'.replace('\\', '\\') > > To me, Python will interpret '\\\\' to '\\'. And the replace method will > replace '\\' with '\'. So, the result will be 'Hello, \World'. But it's give > me 'Hello, \\\\World'. > > The result I want form the code is 'Hello, \World'.
You're replacing with the same as the source string. That's not going to change anything. The first thing to get your head around is Python string literals. You'll find them well described in the online tutorial, or poke around in the interactive interpreter. Once you master that, you should be able to understand what you're trying to do here. ChrisA -- https://mail.python.org/mailman/listinfo/python-list