How to add each item in a list to the previous one in Python?
<p>I have a list and I want to add each element in the list to the previous one. For example if I have the list <code>(1,1,3,3,4)</code>, I want the program to output <code>(1,2,5,8,12)</code>. </p>

<pre><code>for i in range(1, len(arr)):
    arr[i] += arr[i - 1]
</code></pre>

<p>more efficient than Joran Beasley loop</p>

python list