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.
The be
num = ['1', '2', '', '6'] L = [int(n) for n in num if n] ave = sum(L)/float(len(L)) if L else '-'
or
num = ['1', '2', '', '6'] L = [float(n) for n in num if n] avg = sum(L)/len(L) if L else '-'