My function doesn't return a value, can't figure out why
<p>The function is supposed to open a csv file that has data in this format</p>

<p>"polling company,date range,how many polled,margin of error,cruz,kasich,rubio,trump"</p>

<p>When I run this function, read_data_file, there is no output, which I don't understand since I am returning the poll_data. I don't believe there is an issue with the rest of the code as if I replaced 'return poll data' with 'print(poll_data)' there is the desired output. </p>

<p>I am a noob at this and don't have a full grasp of return. </p>

<pre><code>def read_data_file(filename):
    file = open(filename, 'r')
    poll_data = []
    for data in file:
        data = data.strip('\n')
        data = data.split(',')
        poll_data.append(data)
    return poll_data


read_data_file('florida-gop.csv')
</code></pre>

<p>you changed that last line in the function from <code>print</code> to <code>return</code>.  So, when you call your function as such:</p>

<p><code>read_data_file('florida-gop.csv')</code></p>

<p>it <em>does</em> return that data.  It's sitting right there!  But then your script ends, doing nothing with that data.  so, instead, do something like this:</p>

<pre><code>data = read_data_file('florida-gop.csv')
print(data)
</code></pre>

<p>a short addendum - political data is an excellent way to learn data manipulation with Python and, if so inclined, Python itself.  I'd recommend the O'Reilly books on data &amp; Python - but that's outside the scope of this question.</p>

python function return