[Tutor] For loop breaking string methods
C M Caine
cmcaine at googlemail.com
Tue Apr 27 01:40:40 CEST 2010
On 26 April 2010 23:45, Alan Gauld <alan.gauld at btinternet.com> wrote:
> "C M Caine" <cmcaine at googlemail.com> wrote
>> My intention now is to modify list contents in the following fashion:
>> for index, value in enumerate(L):
>> L = some_func(value)
> I think you mean:
> L[index] = some_func(value)
Yes, I do
>> Is this the standard method?
> Or use a List copmprehension.
> L = [some_func(value) for value in L]
> I'd say nowadays that the comprehension was most common.
> Alan Gauld
> Author of the Learn to Program web site
Thanks, I can see why the comprehensions are more popular.
More information about the Tutor