TAGS :Viewed: 15 - Published at: a few seconds ago

[ Passing a list through a function python3.4 windows ]

I am trying to pass a list through a function, but I only get results from first value in list, how do I get the rest?

filetype = ('HDR','ILD','STL','TLR')

f= open ("C:\Console2\word\\testfile.test",'rt')
reader = csv.reader(f)

def filetocsv(ftype):
    typerow = [row for row in reader if row[0] == ftype]
    f.seek(0)
    return (typerow)

def passfiles(alist):
    for filenames in alist:
        values = filetocsv(filenames)
        return (values)

print (passfiles(filetype))

Answer 1


def passfiles(alist):
    values = []
    for filenames in alist:
        values.append(filetocsv(filenames))
    return values