Possible Duplicate:
Only index needed: enumerate or (x)range?
Which of these would be considered better/clearer/faster/more 'Pythonic'? I don't care about the content of the list L
, just how long it is.
a = [f(n) for n, _ in enumerate(L)]
or
a = [f(n) for n in range(len(L))]
If it makes any difference, the function f
makes use of len(list)
as well.