$ 0 0 Instead of casting to float, you can add 0.0 to the sum:def avg(l): return sum(l, 0.0) / len(l)