title: Average of a list of numbers, stored as strings in a Python list
body: <p>I want to calculate the average value of several lists in python. These lists contain numbers as strings. Empty string isn't zero, it means a missing value. </p>
  
  <p>The best I could come up with is this. Is there a more elegant, succinct &amp; efficient way of writing this?</p>
  
  <pre><code>num    = ['1', '2', '', '6']
  total  = sum([int(n) if n else 0 for n in num])
  length = sum([1 if n else 0 for n in num])
  ave    = float(total)/length if length &gt; 0 else '-'
  </code></pre>
  
  <p>P.S. I'm using Python 2.7.x but recipes for Python 3.x are welcome</p>