title: python3 functional programming: Accumulating items from a different list into an initial value
body: <p>I have some code that performs the following operation, however I was wondering if there was a more efficient and understandable way to do this. I am thinking that there might be something in <code>itertools</code> or such that might be designed to perform this type of operation.</p>
  
  <p>So I have a list of integers the represents changes in the number of items from one period to the next. </p>
  
  <pre><code>x = [0, 1, 2, 1, 3, 1, 1]
  </code></pre>
  
  <p>Then I need a function to create a second list that accumulates the total number of items from one period to the next. This is like an <code>accumulate</code> function, but with elements from another list instead of from the same list.</p>
  
  <p>So I can start off with an initial value <code>y = 3</code>.</p>
  
  <p>The first value in the list <code>y = [3]</code>. The I would take the second 
  element in <code>x</code> and add it to the list, so that means <code>3+1 = 4</code>. Note that I take the second element because we already know the first element of <code>y</code>. So the updated value of <code>y</code> is <code>[3, 4]</code>. Then the next iteration is <code>4+2 = 6</code>. And so forth. </p>
  
  <p>The code that I have looks like this:</p>
  
  <pre><code>def func():
      x = [0, 1, 2, 1, 3, 1, 1]
      y = [3]
  
      for k,v in enumerate(x):
          y.append(y[i] + x[i])
      return y
  </code></pre>
  
  <p>Any ideas?</p>