Taylor Patterson Taylor Patterson - 25 days ago 12
Python Question

How to do I call this function in Python?

I'm very new to Python and I can't seem to get functions down. I understand what they do and how to write them, but I don't know how to call them, especially when it comes to parameters.

import csv

def get_data_list(file):
data_file = open("table.csv", "r")
data_list = []
for line_str in data_file:
data_list.append(line_str.strip().split(','))
return data_list

Answer

Don't know what you are trying to do inside your function. But you can call like this

import csv

def get_data_list(file):
    data_file = open("table.csv", "r")
    data_list = []
    for line_str in data_file:
        data_list.append(line_str.strip().split(','))
        return data_list

get_data_list("abc.csv")
Comments