data = [3, 7, 22, -3, 5, -23, 16] result = reduce(lambda a, b: a+[a[-1]+b], data, [0])[1:] print result
Standard input is empty
[3, 10, 32, 29, 34, 11, 27]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!