On 7/3/2009 1:21 PM Kent Johnson said...
On Fri, Jul 3, 2009 at 3:49 PM, Dinesh B
Vadhia<[email protected]> wrote:
d = [0, 8, 4, 4, 4, 7, 2, 5, 1, 1, 5, 11, 11, 1, 6, 3, 5, 6, 11, 1]

and we want:

[0, 8, 12, 16, 20, 27, 29, 34, 35, 36, 41, 52, 63, 64, 70, 73, 78, 84, 95,
96]
dd = [ sum(d[:j]) for j in range(len(d)) ][1:]

gives:

[0, 8, 12, 16, 20, 27, 29, 34, 35, 36, 41, 52, 63, 64, 70, 73, 78, 84, 95]

In [9]: [ sum(d[:j+1]) for j in range(len(d)) ]
Out[9]: [0, 8, 12, 16, 20, 27, 29, 34, 35, 36, 41, 52, 63, 64, 70, 73,
78, 84, 95, 96]

So, did we get an 'A'...

Emile

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to