[Tutor] For loop breaking string methods
alan.gauld at btinternet.com
Tue Apr 27 00:45:58 CEST 2010
"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)
> 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.
Author of the Learn to Program web site
More information about the Tutor