title: Sum / Average an attribute of a list of objects
body: <p>Lets say I have class <code>C</code> which has attribute <code>a</code>.</p>
  
  <p>What is the best way to get the sum of <code>a</code> from a list of <code>C</code> in Python?</p>
  
  <hr>
  
  <p>I've tried the following code, but I know that's not the right way to do it:</p>
  
  <pre><code>for c in c_list:
      total += c.a
  </code></pre>