strip char from list of strings
laurentluce49 at yahoo.com
Tue May 19 10:55:44 EDT 2009
I had a simple loop stripping each string but I was looking for
something concise and efficient. I like the following answer:
x = [s.rstrip('\n') for s in x]
David Stanek wrote:
> On Mon, May 18, 2009 at 3:30 PM, Laurent Luce <laurentluce49 at yahoo.com> wrote:
>> I have the following list:
>> [ 'test\n', test2\n', 'test3\n' ]
>> I want to remove the '\n' from each string in place, what is the most efficient way to do that ?
> What have you tried so far?
More information about the Python-list