cut off \n

Andrew Wilkinson ajw126 at NOSPAMyork.ac.uk
Mon Jun 9 18:10:35 CEST 2003


Andrew Wilkinson wrote:
> Unfortunatly without a single line if-expression in Python I can't think
> of a single line solution to this problem.

I don't like replying to myself, but having seen Alan Kennedy's response I
was reminded that a single line solution would be...

newlist = map(lambda x: x.rstrip(), yourlist)

HTH,
Andrew





More information about the Python-list mailing list