On Mon, May 18, 2009 at 8: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 ? > > Regards, > > Laurent > -- > http://mail.python.org/mailman/listinfo/python-list > >>> s = [ 'test\n', test2\n', 'test3\n' ] >>> [i.strip() for i in s] ['test', 'test2', 'test3'] >>> map(str.strip, s) ['test', 'test2', 'test3'] I'm not sure which one of these is more efficient, but it probably doesn't really matter.
-- http://mail.python.org/mailman/listinfo/python-list