Index error, csv files


#1

Let's say I have a csv file with this in it:

> Luke,4
> Michael,6

If I run this code, it always returns 'IndexError: list index out of range':

import csv

with open('test.csv', 'r') as f:
    reader = csv.reader(f)
    for row in reader:
        n = row[0]
        print(n)

If I comment out the n = row[0] and change it for print(row), it prints out:

['Luke', '4']
['Michael', '5']
[]

That extra list is causing the problem but how do I get rid of it?? Any help would be much appreciated!