title: python summing elements in list: first + last, from last to first
body: <p>I'd like to sum the the last element and first element in a list, then pop off the last element and set that value to the 2nd, 3rd, 4th to last elements to nth - 1 size. Looking something like this:</p>
  
  <pre><code>[1,1,1,1]
  [1,1,2]
  [1,3]
  [4]
  </code></pre>
  
  <p>This is in the context of finding all the possible sums to a number. In the previous example they sum to 4. So far what I have is:</p>
  
  <pre><code>d = [1,1,1,1,1,1,1,1,1,1]
  for x in range(1, len(d)+1):
      d[-x] = (sum(d[:1]) + d[-x])
  </code></pre>
  
  <p>Giving me this:</p>
  
  <pre><code>[1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
  [1, 1, 1, 1, 1, 1, 1, 1, 2, 2]
  [1, 1, 1, 1, 1, 1, 1, 2, 2, 2]
  [1, 1, 1, 1, 1, 1, 2, 2, 2, 2]
  [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
  [1, 1, 1, 1, 2, 2, 2, 2, 2, 2]
  [1, 1, 1, 2, 2, 2, 2, 2, 2, 2]
  [1, 1, 2, 2, 2, 2, 2, 2, 2, 2]
  [1, 2, 2, 2, 2, 2, 2, 2, 2, 2]
  [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
  </code></pre>
  
  <p>P.S. when I try </p>
  
  <pre><code>d.pop()
  </code></pre>
  
  <p>After the assignment block it gives even stranger results.</p>