Computing the sum of the numbers with a define statement-python
<pre><code>data = [92.5, 87.7, 74.8, 93., 91.7, 90.0, 90.3, 92.5, 100.0, 
  100.0, 35.7, 37.4, 21.0]

def data_sum(data):
    total=0.0
    for element in data:
        total+=element
    return total
</code></pre>

<p>My task is to find the sum of the list above and that is what I came up with so far, however when I go to run the file it returns empty. Thanks for your time.</p>

<p>You need to call your function like the below example:</p>

<pre><code>data = [92.5, 87.7, 74.8, 93., 91.7, 90.0, 90.3, 92.5, 100.0,
        100.0, 35.7, 37.4, 21.0]


def data_sum(data):
    total = 0.0
    for element in data:
        total += element
    return total

print data_sum(data)
</code></pre>

<p>Another possible ways to sum values from a list are using the builtin-functions  <a href="https://docs.python.org/2/library/functions.html#sum" rel="nofollow">sum</a> or <a href="https://docs.python.org/2/library/functions.html#reduce" rel="nofollow">reduce</a>, like this:</p>

<pre><code>print sum(data)
print reduce(lambda x, y: x + y, data)
</code></pre>

python python-2.7