[Tutor] Iterating through a list of strings

Stefan Behnel stefan_ml at behnel.de
Mon May 3 10:55:11 CEST 2010


Luke Paireepinart, 03.05.2010 10:27:
> On Mon, May 3, 2010 at 1:49 AM, Stefan Behnel wrote:
>>                 line = line.split('%', 1)[0]
>
> lines = [line[:line.index('%')] for line in ...

Agreed that

     line = line[:line.index('%')]

is slightly more readable than

     line = line.split('%', 1)[0]

Stefan



More information about the Tutor mailing list