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>Your code is fine. You are not making any call to this function, that is why your code is not executing. You can call your function as:</p>

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

<p>However, there is <code>sum()</code> function in Python that returns the sum of the <code>list</code> if the list is of numeric type. Ideal way to get the sum of numeric list is by using <a href="https://docs.python.org/2/library/functions.html#sum" rel="nofollow"><code>sum()</code></a>. Hence your code should be:</p>

<pre><code>sum(data)
</code></pre>

<p>where <code>data</code> is the <code>list</code> as is mentioned in the question. </p>

python python-2.7