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>Continuing from the above(or not so above anymore xD) answer...</p>

<p>the full code would now be,</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


print(read_data_file('florida-gop.csv')) # Before you forgot to print it.
</code></pre>

<p>or exactly like the above answer,</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


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

python function return