Python mean of subset of a list
<p>I want to obtain a list of means from a list. To demonstrate, in my example I have list called listA.</p>

<pre><code>listA = [1,7,8,9,0,7,8,9,9,3,5,3,4,5,3]
</code></pre>

<p>Now I want to create a list of means with another list I have to specify which index ranges I want to take the mean of. I use indexmeans to do that:</p>

<pre><code>indexmeans = [3, 4,3,5]
</code></pre>

<p>So my desired list of means would take the first '3' numbers of listA which have a mean of 5.333. Then I take the 4 numbers after that [9,0,7,8] and take the mean of them which give me a mean of 6. And so on... Exactly all the numbers should be used up as sum(indexmeans) = len(listA)</p>

<pre><code>means = [ 5.333, 6, 7, 4]
</code></pre>