Is there a list comprehension for this?

liam_herron liam_herron at hotmail.com
Tue Nov 21 16:19:04 EST 2006


Given:
dw = [ 1, -1.1, +1.2 ]

Suppose I want to create a list 'w' that is defined as

w[0] = dw[0],
w[1] = w[0] + dw[1],
w[2] = w[1] + dw[2]

Is there a list comprehension or map expression to do it in one or 2
lines.




More information about the Python-list mailing list