if c==excelfiles[1]:
    b ==excelfiles[1]
    wb = xlrd.open_workbook(a)
    wb.sheet_names()
    sh = wb.sheet_by_index(0)
    for rownum in range(sh.nrows):
        print sh.row_values(rownum)

for i in range(sheet.nrows):
    cashflow = [sheet.cell_value(i,0)],[sheet.cell_value(i,1)],[sheet.cell_value(i,2)]
    print cashflow

def npv(rate, cashflow):
    value = cashflow[1] * ((1 + rate/100) ** (12 - cashflow[0]))
    FV = 0
    FV += value
    return FV

def irr(cashflow, iterations = 100):
    rate = 1.0
    
    i = 0
    while (cashflow[0][1] == 0):
        i += 1
    
    investment = cashflow[i][1]
    
    for i in range(1, iterations+1):
        rate *= (1 - (npv(rate, cashflow) / investment))
        return rate

r = irr(cashflow) # why is list index out of range?
print r
