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 <laurentluc...@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?
> 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to